From afbd2d68f7e3e23b49033b1c8c6831cee91a6214 Mon Sep 17 00:00:00 2001 From: Sanjoth J Rai Date: Sun, 30 May 2021 00:29:41 +0530 Subject: [PATCH 1/2] Update unit-testing docs according to change in Jest v27.0.0 for createTransformer --- docs/docs/how-to/testing/unit-testing.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/docs/how-to/testing/unit-testing.md b/docs/docs/how-to/testing/unit-testing.md index 07e37104d43f4..71f64a70c386f 100644 --- a/docs/docs/how-to/testing/unit-testing.md +++ b/docs/docs/how-to/testing/unit-testing.md @@ -65,9 +65,12 @@ const babelOptions = { presets: ["babel-preset-gatsby"], } -module.exports = require("babel-jest").createTransformer(babelOptions) +module.exports = require("babel-jest").default.createTransformer(babelOptions) ``` +> Note: if you're using Jest 26.6.3 or below, `module.exports` has to be changed to +> `module.exports = require("babel-jest").createTransformer(babelOptions)` + - The next option is `moduleNameMapper`. This section works a bit like webpack rules and tells Jest how to handle imports. You are mainly concerned here with mocking static file imports, which Jest can't From 8c5d52658af90dcab02c395577022ad0101f8039 Mon Sep 17 00:00:00 2001 From: Lennart Date: Mon, 31 May 2021 11:05:52 +0200 Subject: [PATCH 2/2] Update unit-testing.md --- docs/docs/how-to/testing/unit-testing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/how-to/testing/unit-testing.md b/docs/docs/how-to/testing/unit-testing.md index 71f64a70c386f..52cc8400388c7 100644 --- a/docs/docs/how-to/testing/unit-testing.md +++ b/docs/docs/how-to/testing/unit-testing.md @@ -68,7 +68,7 @@ const babelOptions = { module.exports = require("babel-jest").default.createTransformer(babelOptions) ``` -> Note: if you're using Jest 26.6.3 or below, `module.exports` has to be changed to +> **Note:** If you're using Jest 26.6.3 or below, the last line has to be changed to > `module.exports = require("babel-jest").createTransformer(babelOptions)` - The next option is `moduleNameMapper`. This