naviapps / create-nw-react-app

Create NW.js React apps with no build configuration.
MIT License
144 stars 14 forks source link

Error running tests with brand new project #3

Closed sketchbuch closed 6 years ago

sketchbuch commented 6 years ago

I have just installed create-nw-react-app and created a new project. I haven't changed or added anything but have errors with running the test task, the output is:

Determining test suites to run...Error: This promise must be present when running with -o. at /.../my-app/node_modules/jest/node_modules/jest-cli/build/search_source.js:202:17 at Generator.next () at step (/.../my-app/node_modules/jest/node_modules/jest-cli/build/search_source.js:19:362) at /.../my-app/node_modules/jest/node_modules/jest-cli/build/search_source.js:19:592 at new Promise () at /.../my-app/node_modules/jest/node_modules/jest-cli/build/search_source.js:19:273 at SearchSource.getTestPaths (/.../my-app/node_modules/jest/node_modules/jest-cli/build/search_source.js:216:10) at /.../my-app/node_modules/jest/node_modules/jest-cli/build/run_jest.js:44:29 at Generator.next () at step (/.../my-app/node_modules/jest/node_modules/jest-cli/build/run_jest.js:23:380)

I'm using linux in case it matters. start task works fine

naviapis commented 6 years ago

Try adding jest.useFakeTimers(); above your it blocks. https://github.com/facebook/jest/issues/2979

src/App.test.js

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';

jest.useFakeTimers(); // Add

it('renders without crashing', () => {
  const div = document.createElement('div');
  ReactDOM.render(<App />, div);
});

If it seems to work, change the global settings as such.

sketchbuch commented 6 years ago

sadly no, it didn't fix the problem. It isn't that the test are failing. They don't even start.

Some more about my setup: Node 9.2.0 Ubuntu 17.10

And the console output:

Determining test suites to run...Error: This promise must be present when running with -o.
    at /path/to/app/node_modules/jest/node_modules/jest-cli/build/search_source.js:202:17
    at Generator.next (<anonymous>)
    at step (/path/to/app/node_modules/jest/node_modules/jest-cli/build/search_source.js:19:362)
    at /path/to/app/node_modules/jest/node_modules/jest-cli/build/search_source.js:19:592
    at new Promise (<anonymous>)
    at /path/to/app/node_modules/jest/node_modules/jest-cli/build/search_source.js:19:273
    at SearchSource.getTestPaths (/path/to/app/node_modules/jest/node_modules/jest-cli/build/search_source.js:216:10)
    at /path/to/app/node_modules/jest/node_modules/jest-cli/build/run_jest.js:44:29
    at Generator.next (<anonymous>)
    at step (/path/to/app/node_modules/jest/node_modules/jest-cli/build/run_jest.js:23:380)
sketchbuch commented 6 years ago

I also tried using the latest LTS node (8.9.2) with the same result

naviapis commented 6 years ago

fixed it. nw-react-scripts@1.0.4 https://github.com/orta/vscode-jest/issues/142 https://github.com/facebook/jest/issues/4419

package.json

{
  "dependencies": {
-   "nw-react-scripts": "^1.0.3",
+   "nw-react-scripts": "^1.0.4",
  }
}

run update.

npm update

thanks.

sketchbuch commented 6 years ago

This may have something to do with it too:

https://github.com/facebook/jest/issues/4419

sketchbuch commented 6 years ago

Yes, your fix to the version does it! Thanks very much ;)