Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test failed on import #2518

Closed
yosyad opened this issue Jan 6, 2017 · 3 comments
Closed

test failed on import #2518

yosyad opened this issue Jan 6, 2017 · 3 comments

Comments

@yosyad
Copy link

yosyad commented Jan 6, 2017

Hello,

I am trying to run a simple test on js that include some functions that I am export, and some others that I don't.
for example, here is the structure of my js file:

// test1.js
$(document).ready(function() {
   // some events handlers
});

export function func1() { ...}
export function func2() { ...}
export function func3() { ...}

function func4(){ ..}

and my test file look like:

// test1.spec.js 
import {func1, func2, func3} from '../../test1.js';

test('test func1', () => {
  expectfunc1('abc')).toBe(false);
});

due to those files, when I run npm run test test1 I am get:

FAIL  __test__\registration.spec.js
  ● Test suite failed to run

    SyntaxError: Unexpected reserved word

      at transformAndBuildScript (node_modules\jest-cli\node_modules\jest-runtime\build\transform.js:320:12)
      at Object.<anonymous> (__test__\test1.spec.js:1:175)

my npm version is 2.15.9, node version is 4.5.0.

can someone tell me what I am doing wrong, or what is the problem?

@thymikee
Copy link
Collaborator

thymikee commented Jan 6, 2017

It looks like you didn't install babel-jest? This would not be a problem if you used npm 3/4 or yarn.

@thymikee thymikee closed this as completed Jan 6, 2017
@rogeliog
Copy link
Contributor

rogeliog commented Jan 6, 2017

It is probably because test1.spec.js is not getting transpiled, which is why it gives a syntax error with the import

Which version of Jest are you using? You can also print the whole config object by running Jest with --debug

Unfortunately that error in Node 4 is not super helpful. See here for more info #2488 (comment)

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants