I just recreated the project from scratch. Now I suddently are receiving an error with the test suite, when deploying through Seed.
The error I receive is the following:
FAIL tests/billing.test.js
● Test suite failed to run
/tmp/seed/source/tests/billing.test.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { calculateCost } from "../libs/billing-lib";
^^^^^^
SyntaxError: Unexpected token import
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:305:17)
at Generator.next (<anonymous>)
at new Promise (<anonymous>)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.878s
Ran all test suites.
npm ERR! Test failed. See above for more details.
2018/11/24 14:07:38 Error: exec: internal error
Anyone else that have received this error or knows how to fix it?
MacBook-Pro:backend user$ npm run test
> notes-app-api@1.1.2 test /Users/user/workspaces/app/backend
> jest
FAIL tests/billing.test.js
● Test suite failed to run
/Users/user/workspaces/app/backend/tests/billing.test.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { calculateCost } from "../libs/billing-lib";
^
SyntaxError: Unexpected token {
at new Script (vm.js:74:7)
at Generator.next (<anonymous>)
at new Promise (<anonymous>)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 1.277s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! notes-app-api@1.1.2 test: `jest`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the notes-app-api@1.1.2 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/user/.npm/_logs/2018-11-25T19_10_56_468Z-debug.log
MacBook-Pro:backend user$
$ npm install
$ npm run test
> notes-app-api@1.1.0 test /Users/jayair/Desktop/tutorial-project/tutorial-api-jest-test
> jest
PASS tests/billing.test.js
✓ Lowest tier (6ms)
✓ Middle tier (1ms)
✓ Highest tier
Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total
Snapshots: 0 total
Time: 1.902s
Ran all test suites.
I guess it might have something to do with the folder structure? If I clone the repo into a new folder it works fine. But if I clone it into a folder with a parent folder of /backend and no folder named serverless-stack-demo-api it dosen’t work?
Regardless of new clone, I too am getting this error.
macos reports the file-type to be javascript but the error message indicates jest may not consider it javascript.
Has anyone found the root-cause / solution?
Whats the error you are getting? You also might be using an older version of the tutorial. Compare your package.json to the one we are using in the tutorial?