Description
Is this a bug report?
yes
Did you try recovering your dependencies?
yes
(Write your answer here.)
Which terms did you search for in User Guide?
(Write your answer here if relevant.)
Environment
PS ../gold-line-sac > npx create-react-app --info
Environment:
OS: Windows 10
Node: 10.9.0
Yarn: 1.9.4
npm: 6.2.0
Watchman: Not Found
Xcode: N/A
Android Studio: Version 3.1.0.0 AI-173.4819257
Packages: (wanted => installed)
react: ^16.4.2 => 16.4.2
react-dom: ^16.4.2 => 16.4.2
react-scripts: 1.1.5 => 1.1.5
PS ../gold-line-sac >
(paste the output of the command here)
Steps to Reproduce
(Write your steps here:)
-
cd to my-app
-
npm start
-
notice app works importing testobj successfully. Browser displays:
'testob: '+JSON.stringify(testob)
testob: {"k1":"v1","k2":"v2","k3":"v3"} -
npm test
FAIL src\App.test.js
● Test suite failed to runPATH\gold-line-sac\src\m\gold-line-data.mjs:48
export const testobj = {"k1":"v1", "k2":"v2", "k3":"v3"};
^^^^^^SyntaxError: Unexpected token export
at new Script (vm.js:73:7)
at Object. (src/App.js:9:194)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 1.83s
Ran all test suites.
Expected Behavior
I thought the test would pass
Actual Behavior
the test failed saying it encountered a syntax error:
-
npm test
FAIL src\App.test.js
● Test suite failed to runPATH\gold-line-sac\src\m\gold-line-data.mjs:48
export const testobj = {"k1":"v1", "k2":"v2", "k3":"v3"};
^^^^^^SyntaxError: Unexpected token export
at new Script (vm.js:73:7)
at Object. (src/App.js:9:194)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 1.83s
Ran all test suites.
Reproducible Demo
(Paste the link to an example project and exact instructions to reproduce the issue.)
Here is the Reproducible Demo Link
https://github.com/JoeCodeswell/react-test-prob-demo
Instructions to reproduce:
- install the demo code
- run
npm start
- NOTICE app works importing
testobj
, etc successfully. Browser displays:
'testob: '+JSON.stringify(testob)
testob: {"k1":"v1","k2":"v2","k3":"v3"} - run
npm test
- NOTICE test FAILS saying "SyntaxError: Unexpected token export.." When this WORKED in the
npm start
command:
FAIL src\App.test.js
● Test suite failed to run
PATH\gold-line-sac\src\m\gold-line-data.mjs:48
export const testobj = {"k1":"v1", "k2":"v2", "k3":"v3"};
^^^^^^
SyntaxError: Unexpected token export
at new Script (vm.js:73:7)
at Object.<anonymous> (src/App.js:9:194)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 1.83s
Ran all test suites.