Hello.
I want to write tests in normal file itself as described below:
src/add.js
//private
function sum(a, b) {
return a + b;
}
test('adds 1 + 2 to equal 3', () => {
expect(sum(1, 2)).toBe(3);
});
src/subtract.js
//private
function subtract(a, b) {
return a - b;
}
//no test
After running `jest src/*output is as follows:
FAIL src/subtract.js
● Test suite failed to run
Your test suite must contain at least one test.
at ../node_modules/jest/node_modules/jest-cli/build/TestScheduler.js:256:22
But, I want to ignore files don't have any tests.
How can I do it?
Thanks.
Hey @hattys2
Could you share your use case for putting your test within the src file itself? I've yet to see someone have the setup you have.
@natealcedo
Just like src/add.js
I found similar case: https://github.com/facebook/jest/issues/4316
You can add an empty test.skip('skip', () => {}) to the subtract.js file. We won't remove this message nor make it configurable, as we optimize for common use case – this is clearly not one of them.
Thanks. I'll try it.
Most helpful comment
You can add an empty
test.skip('skip', () => {})to thesubtract.jsfile. We won't remove this message nor make it configurable, as we optimize for common use case – this is clearly not one of them.