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

jest crashes after upgrade to v12 #955

Closed
fterlid opened this issue Apr 28, 2016 · 5 comments
Closed

jest crashes after upgrade to v12 #955

fterlid opened this issue Apr 28, 2016 · 5 comments

Comments

@fterlid
Copy link

fterlid commented Apr 28, 2016

After upgrading jest from v11.0.2 to v12, jest crashes immidiately. I'm using a gulp task for running tests. Stack trace:

[13:16:19] Using gulpfile C:\x\gulpfile.js
[13:16:19] Starting 'test'...
Using Jest CLI v12.0.2, jasmine2
TypeError: Not a string or buffer
    at TypeError (native)
    at Hash.update (crypto.js:70:16)
    at C:\x\node_modules\jest-haste-map\src\index.js:148:56
    at Array.forEach (native)
    at Function.getCacheFilePath (C:\x\node_modules\jest-haste-map\src\index.js:148:36)
    at new HasteMap (C:\x\node_modules\jest-haste-map\src\index.js:132:32)
    at createHasteMap (C:\x\node_modules\jest-cli\src\lib\createHasteMap.js:21:10)
    at new TestRunner (C:\x\node_modules\jest-cli\src\TestRunner.js:60:22)
    at runJest (C:\x\node_modules\jest-cli\src\jest.js:150:22)
    at C:\x\node_modules\jest-cli\src\jest.js:245:16

Any ideas? The gulp file is unchanged and worked with v11. The gulp task looks like this:

gulp.task('test', function(done) {
    var jestConfig = {
        rootDir: 'src'
        scriptPreprocessor: '../node_modules/babel-jest',
        unmockedModulePathPatterns: [/*shortened for brevity*/],
        noStackTrace: true,
        verbose: false,
        testFileExtensions: ['test.js']
    };

    jest.runCLI({ config: jestConfig }, './src', function() { done(); });
});
@atecarlos
Copy link

There seems to be an expectation of a name property in the config. It eventually ends up as undefined which causes this error. Adding a name property to your config will let your tests run.

@fterlid
Copy link
Author

fterlid commented Apr 28, 2016

Great, @atecarlos, thanks! I set name to an empty string, and everything seems to work.

I guess there is some documentation and a default value missing.

@fterlid
Copy link
Author

fterlid commented Apr 28, 2016

It seems the name property is picked up from the top-level of package.json when the jest config is stored there. When running jest with e.g. gulp or with the --config option, if the name property is not defined, it will crash.

Would it make sense to set a default value to name? I'm thinking an empty string would be appropriate. It looks like it is used as a filename prefix for cache files, so a more specific default string like 'default-name' migth make for some strange file names.

ghost pushed a commit that referenced this issue May 12, 2016
Summary:
This PR addresses #955. I ran into the same problem when using grunt-jest passing a `config` object in the options. Similar to how it behaves when using `package.json` as the configuration source, I'm defaulting the `name` and `rootDir` when they are not provided.
Closes #976

Differential Revision: D3291480

fbshipit-source-id: 370bb08f360ad6892dbc39055481adb05c5ca8d3
@cpojer
Copy link
Member

cpojer commented May 12, 2016

We fixed this for the next release :)

@cpojer cpojer closed this as completed May 12, 2016
@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 14, 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