Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add describe only and skip tests
  • Loading branch information
mattphillips committed May 27, 2018
commit eb43bb3a27e5b2185d37ff5cd4714d28907e517b
81 changes: 47 additions & 34 deletions integration-tests/__tests__/__snapshots__/each.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`runs only the describe.only.each tests 1`] = `
"PASS __tests__/describe-only.test.js
passes all rows expected true == true
✓ passes
✓ passes
fails all rows expected false == true
○ skipped 1 test

"
`;

exports[`shows error message when not enough arguments are supplied to tests 1`] = `
"FAIL __tests__/each-exception.test.js
✕ throws exception when not enough arguments are supplied $left == $right
Expand Down Expand Up @@ -41,6 +52,8 @@ exports[`shows only the tests without .skip as being ran 1`] = `
✓ passes one row expected true == true
✓ passes one row expected true == true
○ skipped 4 tests
passes all rows expected true == true
○ skipped 2 tests

"
`;
Expand Down Expand Up @@ -115,6 +128,40 @@ exports[`shows the correct errors in stderr when failing tests 1`] = `

at __tests__/failure.test.js:18:18

● array table describe fails on all rows expected a == b › fails

expect(received).toBe(expected) // Object.is equality

Expected: \\"b\\"
Received: \\"a\\"

24 | (left, right) => {
25 | it('fails', () => {
> 26 | expect(left).toBe(right);
| ^
27 | });
28 | }
29 | );

at __tests__/failure.test.js:26:20

● array table describe fails on all rows expected c == d › fails

expect(received).toBe(expected) // Object.is equality

Expected: \\"d\\"
Received: \\"c\\"

24 | (left, right) => {
25 | it('fails', () => {
> 26 | expect(left).toBe(right);
| ^
27 | });
28 | }
29 | );

at __tests__/failure.test.js:26:20

● template table fails on one row expected: true == false

expect(received).toBe(expected) // Object.is equality
Expand Down Expand Up @@ -166,40 +213,6 @@ exports[`shows the correct errors in stderr when failing tests 1`] = `

at __tests__/failure.test.js:49:18

● array table describe fails on all rows expected a == b › fails

expect(received).toBe(expected) // Object.is equality

Expected: \\"b\\"
Received: \\"a\\"

24 | (left, right) => {
25 | it('fails', () => {
> 26 | expect(left).toBe(right);
| ^
27 | });
28 | }
29 | );

at __tests__/failure.test.js:26:20

● array table describe fails on all rows expected c == d › fails

expect(received).toBe(expected) // Object.is equality

Expected: \\"d\\"
Received: \\"c\\"

24 | (left, right) => {
25 | it('fails', () => {
> 26 | expect(left).toBe(right);
| ^
27 | });
28 | }
29 | );

at __tests__/failure.test.js:26:20

● template table describe fails on all rows expected a == b › fails

expect(received).toBe(expected) // Object.is equality
Expand Down
9 changes: 7 additions & 2 deletions integration-tests/__tests__/each.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ const runJest = require('../runJest');
const {extractSummary} = require('../Utils');
const dir = path.resolve(__dirname, '../each');
const SkipOnWindows = require('../../scripts/SkipOnWindows');
const SkipOnJestCircus = require('../../scripts/SkipOnJestCircus');

SkipOnWindows.suite();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, do we need skipping it on windows?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we tried removing this before and it failed 🤷‍♂️

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably add a helper fixing the differing symbols on windows and unix so that the integration tests can run. separate issue, though

SkipOnJestCircus.suite();

test('works with passing tests', () => {
const result = runJest(dir, ['success.test.js']);
Expand Down Expand Up @@ -50,7 +48,14 @@ test('shows only the tests with .only as being ran', () => {

test('shows only the tests without .skip as being ran', () => {
const result = runJest(dir, ['each-skip.test.js']);
const {rest} = extractSummary(result.stderr);
expect(rest).toMatchSnapshot();
expect(result.status).toBe(0);
});

test('runs only the describe.only.each tests', () => {
const result = runJest(dir, ['describe-only.test.js']);
const {rest} = extractSummary(result.stderr);
expect(rest).toMatchSnapshot();
expect(result.status).toBe(0);
});
26 changes: 26 additions & 0 deletions integration-tests/each/__tests__/describe-only.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Copyright (c) 2018-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

describe.only.each([[true, true], [true, true]])(
'passes all rows expected %s == %s',
(left, right) => {
it('passes', () => {
expect(left).toBe(right);
});
}
);

// This failing tests should never because of the above `only` so the suite
// should pass
describe.each([[false, true]])(
'fails all rows expected %s == %s',
(left, right) => {
it('fails', () => {
expect(left).toBe(right);
});
}
);
9 changes: 9 additions & 0 deletions integration-tests/each/__tests__/each-skip.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,12 @@ it.skip.each`
expect(left).toBe(right);
}
);

describe.skip.each([[true, true], [true, true]])(
'passes all rows expected %s == %s',
(left, right) => {
it('passes', () => {
expect(left).toBe(right);
});
}
);