From 4fe07397dd7d8b31c5080580fc6ac93428f46791 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Fri, 9 Oct 2020 14:54:28 +0200 Subject: [PATCH 1/3] chore: add info about ES modules to docs --- docs/ECMAScriptModules.md | 17 +++++++ website/sidebars.json | 1 + .../version-26.0/ECMAScriptModules.md | 17 +++++++ .../version-26.0-sidebars.json | 45 +++++++++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 docs/ECMAScriptModules.md create mode 100644 website/versioned_docs/version-26.0/ECMAScriptModules.md create mode 100644 website/versioned_sidebars/version-26.0-sidebars.json diff --git a/docs/ECMAScriptModules.md b/docs/ECMAScriptModules.md new file mode 100644 index 000000000000..370fb7e7f6fa --- /dev/null +++ b/docs/ECMAScriptModules.md @@ -0,0 +1,17 @@ +--- +id: ecmascript-modules +title: ECMAScript Modules +--- + +Jest ships with _experimental_ support for ECMAScript Modules (ESM). + +> Note that due to its experimental nature there are many bugs and missing features in Jest's implementation, both known and unknown. You should check out the [tracking issue](https://github.com/facebook/jest/issues/9430) and the [label](https://github.com/facebook/jest/labels/ES%20Modules) on the issue tracker for the latest status. + +> Also note that the APIs Jest uses to implement ESM support is still [considered experimental by Node](https://nodejs.org/api/vm.html#vm_class_vm_module) (as of version `14.13.1`). + +With the warnings out of the way, this is how you activate ESM support in your tests. + +1. Ensure you either disable [code transforms](./configuration#transform-objectstring-pathtotransformer--pathtotransformer-object) by passing `transform: {}` or otherwise configure your transformer to emit ESM rather than the default CommonJS (CJS). +1. Execute `node` with `--experimental-vm-modules`, e.g. `node --experimental-vm-modules node_modules/.bin/jest` or `NODE_OPTIONS=--experimental-vm-modules npx jest` etc. +1. Beyond that, we attempt to follow `node`'s logic for activating "ESM mode" (such as looking at `type` in `pakcgae.json` or `mjs` files), see [their docs](https://nodejs.org/api/esm.html#esm_enabling) for details + diff --git a/website/sidebars.json b/website/sidebars.json index de65d7d26007..3c4cc29d4399 100644 --- a/website/sidebars.json +++ b/website/sidebars.json @@ -17,6 +17,7 @@ "manual-mocks", "es6-class-mocks", "bypassing-module-mocks", + "ecmascript-modules", "webpack", "puppeteer", "mongodb", diff --git a/website/versioned_docs/version-26.0/ECMAScriptModules.md b/website/versioned_docs/version-26.0/ECMAScriptModules.md new file mode 100644 index 000000000000..e99402886ec9 --- /dev/null +++ b/website/versioned_docs/version-26.0/ECMAScriptModules.md @@ -0,0 +1,17 @@ +--- +id: version-26.0-ecmascript-modules +title: ECMAScript Modules +original_id: ecmascript-modules +--- + +Jest ships with _experimental_ support for ECMAScript Modules (ESM). + +> Note that due to its experimental nature there are many bugs and missing features in Jest's implementation, both known and unknown. You should check out the [tracking issue](https://github.com/facebook/jest/issues/9430) and the [label](https://github.com/facebook/jest/labels/ES%20Modules) on the issue tracker for the latest status. + +> Also note that the APIs Jest uses to implement ESM support is still [considered experimental by Node](https://nodejs.org/api/vm.html#vm_class_vm_module) (as of version `14.13.1`). + +With the warnings out of the way, this is how you activate ESM support in your tests. + +1. Ensure you either disable [code transforms](./configuration#transform-objectstring-pathtotransformer--pathtotransformer-object) by passing `transform: {}` or otherwise configure your transformer to emit ESM rather than the default CommonJS (CJS). +1. Execute `node` with `--experimental-vm-modules`, e.g. `node --experimental-vm-modules node_modules/.bin/jest` or `NODE_OPTIONS=--experimental-vm-modules npx jest` etc. +1. Beyond that, we attempt to follow `node`'s logic for activating "ESM mode" (such as looking at `type` in `pakcgae.json` or `mjs` files), see [their docs](https://nodejs.org/api/esm.html#esm_enabling) for details diff --git a/website/versioned_sidebars/version-26.0-sidebars.json b/website/versioned_sidebars/version-26.0-sidebars.json new file mode 100644 index 000000000000..c69d3ac005d8 --- /dev/null +++ b/website/versioned_sidebars/version-26.0-sidebars.json @@ -0,0 +1,45 @@ +{ + "version-26.0-docs": { + "Introduction": [ + "version-26.0-getting-started", + "version-26.0-using-matchers", + "version-26.0-asynchronous", + "version-26.0-setup-teardown", + "version-26.0-mock-functions", + "version-26.0-jest-platform", + "version-26.0-jest-community", + "version-26.0-more-resources" + ], + "Guides": [ + "version-26.0-snapshot-testing", + "version-26.0-tutorial-async", + "version-26.0-timer-mocks", + "version-26.0-manual-mocks", + "version-26.0-es6-class-mocks", + "version-26.0-bypassing-module-mocks", + "version-26.0-ecmascript-modules", + "version-26.0-webpack", + "version-26.0-puppeteer", + "version-26.0-mongodb", + "version-26.0-dynamodb", + "version-26.0-tutorial-jquery", + "version-26.0-watch-plugins", + "version-26.0-migration-guide", + "version-26.0-troubleshooting", + "version-26.0-architecture" + ], + "Framework Guides": [ + "version-26.0-tutorial-react", + "version-26.0-tutorial-react-native", + "version-26.0-testing-frameworks" + ], + "API Reference": [ + "version-26.0-api", + "version-26.0-expect", + "version-26.0-mock-function-api", + "version-26.0-jest-object", + "version-26.0-configuration", + "version-26.0-cli" + ] + } +} From 0e6037f8eac90160ec26f124506d32be38493fa6 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Fri, 9 Oct 2020 15:04:37 +0200 Subject: [PATCH 2/3] prettier --- docs/ECMAScriptModules.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/ECMAScriptModules.md b/docs/ECMAScriptModules.md index 370fb7e7f6fa..bac2b96c4c56 100644 --- a/docs/ECMAScriptModules.md +++ b/docs/ECMAScriptModules.md @@ -14,4 +14,3 @@ With the warnings out of the way, this is how you activate ESM support in your t 1. Ensure you either disable [code transforms](./configuration#transform-objectstring-pathtotransformer--pathtotransformer-object) by passing `transform: {}` or otherwise configure your transformer to emit ESM rather than the default CommonJS (CJS). 1. Execute `node` with `--experimental-vm-modules`, e.g. `node --experimental-vm-modules node_modules/.bin/jest` or `NODE_OPTIONS=--experimental-vm-modules npx jest` etc. 1. Beyond that, we attempt to follow `node`'s logic for activating "ESM mode" (such as looking at `type` in `pakcgae.json` or `mjs` files), see [their docs](https://nodejs.org/api/esm.html#esm_enabling) for details - From 6738c4994a71c822e0350c43bc20d8ea4039137a Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sat, 10 Oct 2020 12:17:20 +0200 Subject: [PATCH 3/3] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Michaƫl Zasso --- docs/ECMAScriptModules.md | 2 +- website/versioned_docs/version-26.0/ECMAScriptModules.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/ECMAScriptModules.md b/docs/ECMAScriptModules.md index bac2b96c4c56..40320348203a 100644 --- a/docs/ECMAScriptModules.md +++ b/docs/ECMAScriptModules.md @@ -13,4 +13,4 @@ With the warnings out of the way, this is how you activate ESM support in your t 1. Ensure you either disable [code transforms](./configuration#transform-objectstring-pathtotransformer--pathtotransformer-object) by passing `transform: {}` or otherwise configure your transformer to emit ESM rather than the default CommonJS (CJS). 1. Execute `node` with `--experimental-vm-modules`, e.g. `node --experimental-vm-modules node_modules/.bin/jest` or `NODE_OPTIONS=--experimental-vm-modules npx jest` etc. -1. Beyond that, we attempt to follow `node`'s logic for activating "ESM mode" (such as looking at `type` in `pakcgae.json` or `mjs` files), see [their docs](https://nodejs.org/api/esm.html#esm_enabling) for details +1. Beyond that, we attempt to follow `node`'s logic for activating "ESM mode" (such as looking at `type` in `package.json` or `mjs` files), see [their docs](https://nodejs.org/api/esm.html#esm_enabling) for details diff --git a/website/versioned_docs/version-26.0/ECMAScriptModules.md b/website/versioned_docs/version-26.0/ECMAScriptModules.md index e99402886ec9..b99d6400478b 100644 --- a/website/versioned_docs/version-26.0/ECMAScriptModules.md +++ b/website/versioned_docs/version-26.0/ECMAScriptModules.md @@ -14,4 +14,4 @@ With the warnings out of the way, this is how you activate ESM support in your t 1. Ensure you either disable [code transforms](./configuration#transform-objectstring-pathtotransformer--pathtotransformer-object) by passing `transform: {}` or otherwise configure your transformer to emit ESM rather than the default CommonJS (CJS). 1. Execute `node` with `--experimental-vm-modules`, e.g. `node --experimental-vm-modules node_modules/.bin/jest` or `NODE_OPTIONS=--experimental-vm-modules npx jest` etc. -1. Beyond that, we attempt to follow `node`'s logic for activating "ESM mode" (such as looking at `type` in `pakcgae.json` or `mjs` files), see [their docs](https://nodejs.org/api/esm.html#esm_enabling) for details +1. Beyond that, we attempt to follow `node`'s logic for activating "ESM mode" (such as looking at `type` in `package.json` or `mjs` files), see [their docs](https://nodejs.org/api/esm.html#esm_enabling) for details