You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With testEnvironment configuration option a custom test environment can be specified. Babel seems to skip the specified testEnvironment file and only transforms test files. This causes confusion since test code is transformed differently from the testEnvironment file.
Executing above test in a Node 12 environment (which doesn't support optional chaining) will fail with following output:
> jest
FAIL ./optional-chaining.test.js
● Test suite failed to run
/home/runner/jest-playground/custom-environment.js:4
console.log("environment: " + test.a?.b);
^
SyntaxError: Unexpected token '.'
at node_modules/jest-runner/build/runTest.js:259:7
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.077s, estimated 12s
Ran all test suites.
exit status 1
If you comment the line mentioned in the error output (console.log("environment: " + test.a?.b);) it will work just fine, which indicates that optional-chaining.test.js is transformed properly, while custom-environment.js isn't.
Expected behavior
Babel should also transform testEnvironment file (in this case custom-environment.js) just as any other file.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.
🐛 Bug Report
With
testEnvironment
configuration option a custom test environment can be specified. Babel seems to skip the specifiedtestEnvironment
file and only transforms test files. This causes confusion since test code is transformed differently from thetestEnvironment
file.To Reproduce
Steps to reproduce the behavior:
babel.config.js
jest.config.js
custom-environment.js
optional-chaining.spec.js
package.json
Executing above test in a Node 12 environment (which doesn't support optional chaining) will fail with following output:
If you comment the line mentioned in the error output (
console.log("environment: " + test.a?.b);
) it will work just fine, which indicates thatoptional-chaining.test.js
is transformed properly, whilecustom-environment.js
isn't.Expected behavior
Babel should also transform
testEnvironment
file (in this casecustom-environment.js
) just as any other file.Link to repl or repo
https://repl.it/join/kbuocjuy-ysfaran
envinfo
The text was updated successfully, but these errors were encountered: