Closed hjmccain closed 6 years ago
I don't think using src/node_modules
for source code is currently supported. In 2.x alpha releases we support using Lerna or Yarn Workspaces for monorepos so maybe that would help you?
Great — that was the issue. Removed src/node_modules
and moved the contents directly into src
and the tests ran perfectly. And I will look into using Lerna or Yarn Workspaces. Thanks for your help!
I created a brand new create-react-app. I didn't change anything. I open terminal and run jest and get error "SyntaxError: Unexpected token import" - nay ideas?
So I cd'ed into src dir then ran jest again and now its giving a problem with JSX:
I'm having de same problem
@Noitidart @JulianeAlbuquerque
Please run yarn test or npm run test instead of jest
Oh wow thank you so much @bugzpodder!! It works!!
@bugzpodder Im getting another error after installing some packages. It seems its running tests in the 3rd party libs. Shouldnt node_modules be ignored? Am I doing something wrong?
I intsalled redux-persist
.
Writing objects: 100% (7/7), 638 bytes | 0 byt FAIL src\App\index.test.js
● Test suite failed to run
C:\Users\Mercurius\Documents\GitHub\boiler\node_modules\redux-persist\es\storage\index.js:1 ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import createWebStorage from './createWebStorage'; ^^^^^^
SyntaxError: Unexpected token import
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/ScriptTransformer.js:289:17) at Object.<anonymous> (src/App/store/index.js:5:16) at Object.<anonymous> (src/App/index.js:9:14)
Test Suites: 1 failed, 1 total
Tests: 0 total
Hi @Noitidart please file a new issue with appropriate repo steps. If you do yarn test or npm run test it should just work. If not then there must be something that doesn't work and I would have no idea without seeing more information.
Thanks @bugzpodder I'll definitely do that and share link. Really appreicate your attention!
Hey guys... Are there another issue for that? What am I doing wrong? It was working well yesterday, but I tried it again now and I got this >>
FAIL specs/Login.spec.js ● Test suite failed to run
C:\App\projects\contabilidade\fe-contabilidade-client\specs\jest.setup.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import React from 'react';
^^^^^
SyntaxError: Unexpected identifier
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:403:17)
i don't know what is the meaning of this problem
FAIL xxx/__tests__/list.spec.js
● Test suite failed to run
/xxxx/__tests__/list.spec.js:2
import * as React from "react";
^^^^^^
SyntaxError: Unexpected token import
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/ScriptTransformer.js:289:17)
at handle (node_modules/worker-farm/lib/child/index.js:44:8)
at process.<anonymous> (node_modules/worker-farm/lib/child/index.js:51:3)
at emitTwo (events.js:126:13)
I am using create-react-app and having trouble running Jest.
When I attempt to import a React component into my test file, I get an error when I
yarn test
:This is what my test file looks like:
However, the error does not get thrown if I'm at the root of the
src
file, importing myindex.js
. At that point, the error gets thrown in the first file thatindex.js
imports. For example:test.test.js
index.js
terminal output
It seems like, in the context of Jest, Babel isn't able to compile the files in
src/node_modules
properly. I'm just at a loss as to how to correct that! Any insights would be appreciated.Please let me know if you need more code, context, or info! I'm new at this :)