-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add mjs wrapper * use import instead of require for support code * support es2018 compile target * separate cli for esm, override importer fn * include mjs wrapper in package * add feature for testing with esm * for now, bail if on windows * all same exports as cjs entry point * pivot to single binary with flag and hack to import import * fix feature file wording * fix lint and test * skip esm scenario if not node 12 or higher * make it fail with imports in cucumber.js file * make it work for cucumber.js file * make it fail for a custom formatter * avoid collision * make importing formatters work * make custom snippets work * Include .mjs files by default if using ESM * test with and without parallel * unignore windows in esm tests * add cli doc * add changelog entry * rename this * sometimes use `pathToFileURL` as appropriate * readd semi * rework config builder tests * further resimplify test * improve doco * include importer.js in src, copy at build time * link to docs from changelog entry * put wrapper.mjs in src as well
- Loading branch information
1 parent
e2fd32a
commit 1a8bc79
Showing
21 changed files
with
348 additions
and
68 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
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,80 @@ | ||
Feature: ES modules support | ||
|
||
cucumber-js works with native ES modules, via a Cli flag `--esm` | ||
|
||
@esm | ||
Scenario Outline: native module syntax works when using --esm | ||
Given a file named "features/a.feature" with: | ||
""" | ||
Feature: | ||
Scenario: one | ||
Given a step passes | ||
Scenario: two | ||
Given a step passes | ||
""" | ||
And a file named "features/step_definitions/cucumber_steps.js" with: | ||
""" | ||
import {Given} from '@cucumber/cucumber' | ||
Given(/^a step passes$/, function() {}); | ||
""" | ||
And a file named "cucumber.js" with: | ||
""" | ||
export default { | ||
'default': '--format message:messages.ndjson', | ||
} | ||
""" | ||
And a file named "custom-formatter.js" with: | ||
""" | ||
import {SummaryFormatter} from '@cucumber/cucumber' | ||
export default class CustomFormatter extends SummaryFormatter {} | ||
""" | ||
And a file named "custom-snippet-syntax.js" with: | ||
""" | ||
export default class CustomSnippetSyntax { | ||
build(opts) { | ||
return 'hello world' | ||
} | ||
} | ||
""" | ||
When I run cucumber-js with `<options> --format ./custom-formatter.js --format-options '{"snippetSyntax": "./custom-snippet-syntax.js"}'` | ||
Then it passes | ||
Examples: | ||
| options | | ||
| --esm | | ||
| --esm --parallel 2 | | ||
|
||
@esm | ||
Scenario: .mjs support code files are matched by default when using --esm | ||
Given a file named "features/a.feature" with: | ||
""" | ||
Feature: | ||
Scenario: | ||
Given a step passes | ||
""" | ||
And a file named "features/step_definitions/cucumber_steps.mjs" with: | ||
""" | ||
import {Given} from '@cucumber/cucumber' | ||
Given(/^a step passes$/, function() {}); | ||
""" | ||
When I run cucumber-js with `--esm` | ||
Then it passes | ||
|
||
Scenario: native module syntax doesn't work without --esm | ||
Given a file named "features/a.feature" with: | ||
""" | ||
Feature: | ||
Scenario: | ||
Given a step passes | ||
""" | ||
And a file named "features/step_definitions/cucumber_steps.js" with: | ||
""" | ||
import {Given} from '@cucumber/cucumber' | ||
Given(/^a step passes$/, function() {}); | ||
""" | ||
When I run cucumber-js | ||
Then it fails |
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
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
Oops, something went wrong.