Skip to content

Commit

Permalink
test(e2e): module-types
Browse files Browse the repository at this point in the history
`esModule: true` is now `type: 'module'`.  Test updated to reflect that.
  • Loading branch information
appsforartists committed Nov 30, 2017
1 parent 79d9716 commit fa24808
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 15 deletions.
7 changes: 6 additions & 1 deletion static/context.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
</script>
<!-- Dynamically replaced with <script> tags -->
%SCRIPTS%
<script type="text/javascript">
<!-- Since %SCRIPTS% might include modules, the `loaded()` call needs to be in a module too.
This ensures all the tests will have been declared before karma tries to run them. -->
<script type="module">
window.__karma__.loaded();
</script>
<script nomodule>
window.__karma__.loaded();
</script>
</body>
Expand Down
7 changes: 6 additions & 1 deletion static/debug.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@
</script>
<!-- Dynamically replaced with <script> tags -->
%SCRIPTS%
<script type="text/javascript">
<!-- Since %SCRIPTS% might include modules, the `loaded()` call needs to be in a module too.
This ensures all the tests will have been declared before karma tries to run them. -->
<script type="module">
window.__karma__.loaded();
</script>
<script nomodule>
window.__karma__.loaded();
</script>
</body>
Expand Down
28 changes: 19 additions & 9 deletions test/e2e/module-types.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,33 @@ Feature: ES Modules
As a person who wants to write great tests
I want to use different script types with Karma.

Scenario: Simple middleware
Scenario: Globbing modules, with both .js and .mjs extensions
Given a configuration with:
"""
files = [
{ pattern: 'modules/plus.js', esModule: false },
{ pattern: 'modules/minus.mjs', esModule: true },
'modules/test.js'
{ pattern: 'modules/**/*.js', type: 'module' },
{ pattern: 'modules/**/*.mjs', type: 'module' },
];
browsers = ['Firefox'];
// 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-jasmine',
'karma-mocha',
'karma-chai',
'karma-firefox-launcher'
];
"""
When I start Karma
Then it passes with:
Then it passes with like:
"""
..
Firefox
Executed 4 of 4 SUCCESS
"""
4 changes: 2 additions & 2 deletions test/e2e/support/modules/__tests__/minus.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { minus } from '../minus.mjs'

describe('minus', function () {
it('should pass', function () {
expect(true).toBe(true)
expect(true).to.be.true
})

it('should work', function () {
expect(minus(3, 2)).toBe(1)
expect(minus(3, 2)).to.equal(1)
})
})
4 changes: 2 additions & 2 deletions test/e2e/support/modules/__tests__/plus.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { plus } from '../plus.js'

describe('plus', function () {
it('should pass', function () {
expect(true).toBe(true)
expect(true).to.be.true
})

it('should work', function () {
expect(plus(1, 2)).toBe(3)
expect(plus(1, 2)).to.equal(3)
})
})

0 comments on commit fa24808

Please sign in to comment.