You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+14-11Lines changed: 14 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,9 +2,10 @@
2
2
[Karma](http://karma-runner.github.io) preprocessor to resolve ES6 modules.
3
3
4
4
## The problem
5
-
Karma can natively run ES6 modules when using a suitable environment (a modern browser). Browsers module implementation is limited however to local modules (i.e. `./foo.js`) and browsers will not resolve paths missing extension leaving that to the server.
5
+
Karma can natively run ES6 modules when running in a suitable environment (a modern browser). Browsers module implementation is limited however to local modules (i.e. `./foo.js`) and browsers will not resolve paths missing extension leaving that to the server.
6
+
7
+
This preprocessor solves both problems by rewriting import declarations on the fly and replacing aliased paths with absolute ones as well as adding extensions if necessary allowing for native ES6 modules testing without compiling or bundling.
6
8
7
-
This preprocessor solves both problems by rewriting import declarations on the fly and replacing aliased path with relative ones as well as adding extensions if necessary allowing for native ES6 modules testing without compiling or bundling.
8
9
9
10
## Installation
10
11
```bash
@@ -18,16 +19,18 @@ Preprocessor is configured with `moduleResolverPreprocessor` field:
18
19
module.exports= (config) => {
19
20
config.set({
20
21
files: [
21
-
{type:'module', pattern:'test/**/*.js'},
22
-
{type:'module', pattern:'alias-root/**/*.js'}
22
+
{type:'module', pattern:'./test/**/*.js'},
23
+
{type:'module', pattern:'./project/**/*.js'}
23
24
],
24
25
preprocessors: {
25
26
'test/**/*.js': ['module-resolver']
26
27
},
27
28
moduleResolverPreprocessor: {
28
29
addExtension:'js',
29
30
customResolver:null,
30
-
aliases: {}
31
+
aliases: {
32
+
project:"./project"
33
+
}
31
34
}
32
35
});
33
36
};
@@ -54,7 +57,7 @@ import Bar from 'alias/bar.js';
54
57
55
58
Default value: `{}`
56
59
57
-
A hash map containing alias names and paths relative from karma`basePath`.
60
+
A hash map containing alias names and paths relative to Karma`basePath`.
@@ -78,7 +81,7 @@ A function to be called instead of normal rewriting.
78
81
79
82
Takes a single argument: A string containing imported file path.
80
83
81
-
Return value: string.
84
+
Return value: string, a new file path.
82
85
83
86
Example:
84
87
```js
@@ -93,7 +96,7 @@ import Foo from 'foo';
93
96
importFoofrom'http://example.com/foo';
94
97
```
95
98
96
-
## Karma module support
97
-
As of version 3.0.0 Karma has limited support of modules: It can integrated it, but there's [a bug](https://github.com/karma-runner/karma/issues/2955) preventing tests described in modules from running. It is fixed in develop branch, but there's no release with the fix and no information on when it's going to be available.
99
+
## Karma ES6 modules support
100
+
As of version `3.0.0` Karma has limited support of modules: It can integrate them, but there's [a bug](https://github.com/karma-runner/karma/issues/2955) preventing tests described in modules from running. It is fixed in develop branch, but there's no release with the fix and no information on when it's going to be available.
98
101
99
-
There are some workarounds for the issue: Using `customContextFile` to substitute 3.0.0 `context.html` with a newer one and delaying `__karma__.loaded` call until DOM `load` event, see Karma GitHub for details.
102
+
There are some workarounds for the issue: Using `customContextFile` to substitute `3.0.0``context.html` with a newer one and delaying `__karma__.loaded` call until DOM `load` event. See Karma GitHub for details.
0 commit comments