-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(config): add support for ES modules
- Add support for ES modules via `esModule` property in file config object * test(modules): ensure relative paths work correctly * test(e2e): module-types `esModule: true` is now `type: 'module'`. Test updated to reflect that.
- Loading branch information
1 parent
0f8b2b1
commit e811adb
Showing
7 changed files
with
77 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Feature: ES Modules | ||
In order to use Karma | ||
As a person who wants to write great tests | ||
I want to use different script types with Karma. | ||
|
||
Scenario: Globbing modules, with both .js and .mjs extensions | ||
Given a configuration with: | ||
""" | ||
files = [ | ||
{ pattern: 'modules/**/*.js', type: 'module' }, | ||
{ pattern: 'modules/**/*.mjs', type: 'module' }, | ||
]; | ||
// Chrome fails on Travis, so we must use Firefox (which means we must | ||
// manually enable modules). | ||
customLaunchers = { | ||
FirefoxWithModules: { | ||
base: 'Firefox', | ||
prefs: { | ||
'dom.moduleScripts.enabled': true | ||
} | ||
} | ||
}; | ||
browsers = ['FirefoxWithModules']; | ||
frameworks = ['mocha', 'chai']; | ||
plugins = [ | ||
'karma-mocha', | ||
'karma-chai', | ||
'karma-firefox-launcher' | ||
]; | ||
""" | ||
When I start Karma | ||
Then it passes with like: | ||
""" | ||
Executed 4 of 4 SUCCESS | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { minus } from '../minus.mjs' | ||
|
||
describe('minus', function () { | ||
it('should pass', function () { | ||
expect(true).to.be.true | ||
}) | ||
|
||
it('should work', function () { | ||
expect(minus(3, 2)).to.equal(1) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { plus } from '../plus.js' | ||
|
||
describe('plus', function () { | ||
it('should pass', function () { | ||
expect(true).to.be.true | ||
}) | ||
|
||
it('should work', function () { | ||
expect(plus(1, 2)).to.equal(3) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Some code under test | ||
export function minus (a, b) { | ||
return a - b | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Some code under test | ||
export function plus (a, b) { | ||
return a + b | ||
} |