Closed mix3d closed 5 years ago
@mix3d Can you try renaming babelrc.js
to babel.config.js
and see if it works?
Nope babel.config.js
doesn't affect the jest error
I haven't been able to reproduce this, but I've just updated Vue CLI, which may fix the problem. @mix3d @ecasilla Can you confirm whether you still see this error with a fresh clone? If you still do, can you provide more information about your environment, including operating system, node version, and NPM version?
faced the same issue, updating all dependencies fixed it
@graberzz Strange - all the dependencies should have been relatively up-to-date when cloning. Would you mind sharing exactly which dependencies were causing a problem for you?
Hoping my case helps a bit with reproducing this error.
I found the instance where the unit tests are failing.
At the moment here are my specs and versions:
ProductName: Mac OS X ProductVersion: 10.13.6 BuildVersion: 17G65 Node: v9.10.0 NPM: 6.4.1 Yarn: 1.9.4
I reproduced the getting started steps both using NPM and Yarn. Using NPM ('npm install') makes the test fail and using Yarn ('yarn') makes things go smoothly and are all working.
Steps on cloned repo with directory named 'issue_77' left screen:
Steps on cloned repo with directory named 'issue_77_2' right screen:
I still haven't checked deeper into why this is happening but I'll definitely try and see why the discrepancy and why only using 'npm install' makes the tests break. I'm hoping my observation helps out into helping solve this issue.
I just ran into the same issue, cloned the repo a few days ago. Using npm, jest encounters an unexpected token. Using yarn, it runs fine. Changing babelrc.js to babel.config.js didn't help. Neither did updating the dependencies. I don't want to make my team install yarn when we are already using npm for everything else. I am on windows 10 Node 9.5.0 npm 6.4.1
It looks like the root cause here was a bug in NPM's module resolution. I've just committed a workaround that seems to have fixed it though. If anyone is still encountering the problem, please let me know.
Hi, I've just encountered this issue with npm. Cloned repo -> npm i -> npm run test:unit
Test suite failed to run
/{path-to-propject}/vue-enterprise-boilerplate/tests/unit/setup.js: Unexpected token (84:17)
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:
82 | functional: true,
83 | render(h, { slots }) {
> 84 | return <div>{slots().default}</div>
| ^
85 | },
86 | },
87 | ...(options.stubs || {}),
npm 6.9.0 node v10.14.1
Can you advise please?
I am encountering the same error. npm 6.4.1 node v10.15.3
I believe the problem is now really fixed. For existing projects, downgrading babel-jest
to 23.6.x
is the key, though you'll also have to delete node_modules
and package-lock.json
and reinstall after downgrading, due to a bug in NPM's module resolution.
Still appears to fail on a new clone of the repo (post fix):
git clone https://github.com/chrisvfritz/vue-enterprise-boilerplate.git unit-test-error
cd unit-test-error
yarn
yarn test:unit
With the same error:
Jest encountered an unexpected token
SyntaxError: F:\source\git\unit-test-error\tests\unit\setup.js: Unexpected token (84:17)
82 | functional: true,
83 | render(h, { slots }) {
> 84 | return <div>{slots().default}</div>
| ^
85 | },
86 | },
87 | ...(options.stubs || {}),
Is there a way to temporarily disable all tests until this is resolved (without having to delete the tests) since it prevents you from committing any changes, and also from publishing any npm packages via lerna (which requires you to commit first)?
node 11.15.0 / npm 6.7.0 / yarn 1.13.0 / jest 23.6.0
@bmillspaugh I wasn't able to reproduce the issue and haven't seen it reported again since, so hopefully this was a temporary regression solved in a patch update. For anyone that may want to temporarily disable unit tests in the future, you can do by adding a #
at the beginning of the values of the following scripts in package.json
: test:unit
, test:unit:file
, and test:unit:ci
. That comments them out, essentially making them a noop.
@chrisvfritz I am getting the same error with yarn and npm with versions babel-jest@23.6.x and babel-jest@24.9.0
First time running the project. Cloned,
npm install
'd, and tried a few commands.npm run build
andnpm run dev
both seemed to work, butnpm run unit
fails withComplaining about JSX
return <div>...</div>
Babel isn't running correctly I guess, based on the error message? Even though the babelrc.js file is unchanged?
Unsure how to move forward.