Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I cannot run multiple test files with Jest?

I have just started with Jest today. I have a simple test file in my __tests__ directory. Here is the current test file:

describe('ChangeCalendarView', function() {
    it('true', function() {
        expect(3).toBe(3);
    })
});

This runs with no issue. When I add another file, with the same exact code, other than the description:

describe('ChangeTimePeriod', function() {
    it('true', function() {
        expect(3).toBe(3);
    })
});

Then I get this error:

/usr/local/lib/node_modules/jest-cli/node_modules/node-worker-pool/Worker.js:93
    throw new Error('Received unexpected data from child process: ' + data);
          ^
Error: Received unexpected data from child process: {
  "error": "Error: ENOENT, open '/usr/local/lib/node_modules/jest-cli/.haste_cache/cache-react-calendar-component'\n\n"
}
  at Worker._onStdout (/usr/local/lib/node_modules/jest-cli/node_modules/node-worker-pool/Worker.js:93:11)

Does this make sense to anyone?

like image 556
jhamm Avatar asked Jan 24 '15 19:01

jhamm


2 Answers

If you want to specify exact multiple files to run tests on, just separate files' names with space.

like image 112
Ingo Kodba Avatar answered Sep 20 '22 07:09

Ingo Kodba


The glob patterns Jest uses to detect test files. By default it looks for .js and .jsx files inside of tests folders, as well as any files with a suffix of .test or .spec (e.g. Component.test.js or Component.spec.js). It will also find files called test.js or spec.js. So name your test file with suffix .test .Like pagination.test.js .

like image 31
Ron Lavit Avatar answered Sep 20 '22 07:09

Ron Lavit