Reputation: 39270
Installed jest:
yarn add jest
Add a file in ./src/index.js with the content:
test('First test', () => {
expect(true).toBe(true);
});
Try to run it with:
node node_modules/jest/bin/jest.js src/index.js
or
node node_modules/jest/bin/jest.js ./src/index.js
But all I get is:
No tests found
In /home/me/dev/lib
7 files checked.
testMatch: **/__tests__/**/*.js?(x),**/?(*.)(spec|test).js?(x) - 0 matches
testPathIgnorePatterns: /node_modules/ - 7 matches
Pattern: ./src/index.js - 0 matches
Just would like to run the one file without having to go through the pain of setting up a directory convention or config file. Is this possible?
Upvotes: 0
Views: 4232
Reputation: 897
import LoggerService from '../LoggerService ';
describe('Method called****', () => {
it('00000000', () => {
const logEvent = jest.spyOn(LoggerService , 'logEvent');
expect(logEvent).toBeDefined();
});
});
npm test -- tests/LoggerService .test.ts -t '00000000'
Upvotes: 0
Reputation: 117
From Jest's website
Place your tests in a
__tests__
folder, or name your test files with a .spec.js or .test.js extension. Whatever you prefer, Jest will find and run your tests.
You can see in the test match
testMatch: **/__tests__/**/*.js?(x),**/?(*.)(spec|test).js?(x) - 0 matches
It is looking for files that are .spec or .test and end in .js or .jsx
Upvotes: 1