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
{{ message }}
This repository was archived by the owner on Mar 4, 2025. It is now read-only.
I get the following error when running npx create-nuxt-app appname && cd appname && npm run test.
FAIL test/Logo.spec.js
● Test suite failed to run
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
Here's what you can do:
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/en/configuration.html
Details:
/Users/username/Desktop/appname/test/Logo.spec.js:1
import { mount } from '@vue/test-utils';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at Runtime._execModule (node_modules/jest-runtime/build/index.js:1166:56)
Running coverage on untested files...Failed to collect coverage from /Users/username/Desktop/appname/pages/index.vue
ERROR: /Users/username/Desktop/appname/pages/index.vue: 'import' and 'export' may only appear at the top level (31:0)
29 | //
30 | //
> 31 | import Logo from '~/components/Logo.vue';
| ^
32 | export default {
33 | components: {
34 | Logo
STACK: SyntaxError: /Users/username/Desktop/appname/pages/index.vue: 'import' and 'export' may only appear at the top level (31:0)
29 | //
30 | //
> 31 | import Logo from '~/components/Logo.vue';
| ^
32 | export default {
33 | components: {
34 | Logo
at Parser._raise (/Users/username/Desktop/appname/node_modules/@babel/parser/lib/index.js:754:17)
at Parser.raiseWithData (/Users/username/Desktop/appname/node_modules/@babel/parser/lib/index.js:747:17)
at Parser.raise (/Users/username/Desktop/appname/node_modules/@babel/parser/lib/index.js:741:17)
at Parser.parseStatementContent (/Users/username/Desktop/appname/node_modules/@babel/parser/lib/index.js:11284:18)
at Parser.parseStatement (/Users/username/Desktop/appname/node_modules/@babel/parser/lib/index.js:11193:17)
at Parser.parseBlockOrModuleBlockBody (/Users/username/Desktop/appname/node_modules/@babel/parser/lib/index.js:11768:25)
at Parser.parseBlockBody (/Users/username/Desktop/appname/node_modules/@babel/parser/lib/index.js:11754:10)
at Parser.parseBlock (/Users/username/Desktop/appname/node_modules/@babel/parser/lib/index.js:11738:10)
at Parser.parseFunctionBody (/Users/username/Desktop/appname/node_modules/@babel/parser/lib/index.js:10745:24)
at Parser.parseFunctionBodyAndFinish (/Users/username/Desktop/appname/node_modules/@babel/parser/lib/index.js:10728:10)
----------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files | 0 | 0 | 0 | 0 |
----------|---------|----------|---------|---------|-------------------
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 1.276 s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! appname@1.0.0 test: `jest`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the appname@1.0.0 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/username/.npm/_logs/2020-06-20T18_31_43_020Z-debug.log
This is the content of that .log file
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/usr/local/Cellar/node/14.4.0/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'run',
1 verbose cli 'test'
1 verbose cli ]
2 info using npm@6.14.4
3 info using node@v14.4.0
4 verbose run-script [ 'pretest', 'test', 'posttest' ]
5 info lifecycle appname@1.0.0~pretest: appname@1.0.0
6 info lifecycle appname@1.0.0~test: appname@1.0.0
7 verbose lifecycle appname@1.0.0~test: unsafe-perm in lifecycle true
8 verbose lifecycle appname@1.0.0~test: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/username/Desktop/appname/node_modules/.bin:/usr/local/sbin:/usr/local/opt/php@7.2/sbin:/usr/local/opt/php@7.2/bin:/Users/username/.platformsh/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
9 verbose lifecycle appname@1.0.0~test: CWD: /Users/username/Desktop/appname
10 silly lifecycle appname@1.0.0~test: Args: [ '-c', 'jest' ]
11 silly lifecycle appname@1.0.0~test: Returned: code: 1 signal: null
12 info lifecycle appname@1.0.0~test: Failed to exec test script
13 verbose stack Error: appname@1.0.0 test: `jest`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:315:20)
13 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:315:20)
13 verbose stack at maybeClose (internal/child_process.js:1051:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
14 verbose pkgid appname@1.0.0
15 verbose cwd /Users/username/Desktop/appname
16 verbose Darwin 19.5.0
17 verbose argv "/usr/local/Cellar/node/14.4.0/bin/node" "/usr/local/bin/npm" "run" "test"
18 verbose node v14.4.0
19 verbose npm v6.14.4
20 error code ELIFECYCLE
21 error errno 1
22 error appname@1.0.0 test: `jest`
22 error Exit status 1
23 error Failed at the appname@1.0.0 test script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
This was not happening before, only since I updated "create-nuxt-app" to version 3.0.0.
Any help will be truly appreciated.
Thanks
Hi guys,
I get the following error when running
npx create-nuxt-app appname && cd appname && npm run test.This is the content of that .log file
This was not happening before, only since I updated "create-nuxt-app" to version 3.0.0.
Any help will be truly appreciated.
Thanks