"npm start" app works, "npm test" fails test with syntax error on export
See original GitHub issueIs 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 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.
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 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.
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.
Issue Analytics
- State:
- Created 5 years ago
- Comments:8
Hi, Ricardo.
I am not “using” ReactDOM . This is the way create-react-app comes out of the box.
I am reporting a create-react-app bug.
I expect, if i do nothing to cause a problem, that running
npm test
on an almost out of the box create-react-app, will not display a failure message.I know i have not caused a problem because when i run
npm start
, the app works. It imports testobj successfully. the browser displays: 'testob: '+JSON.stringify(testob) testob: {“k1”:“v1”,“k2”:“v2”,“k3”:“v3”}Thanks for your comment, Ricardo. Love and peace, Joe
This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.