Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding xit and fit to the test result locations #6482

Merged
merged 16 commits into from
Oct 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
- `[jest-jasmine2]` Better error message when a describe block is empty ([#6372](https://github.com/facebook/jest/pull/6372))
- `[jest-jasmine2]` Pending calls inside async tests are reported as pending not failed ([#6782](https://github.com/facebook/jest/pull/6782))
- `[jest-circus]` Better error message when a describe block is empty ([#6372](https://github.com/facebook/jest/pull/6372))
- `[jest-jasmine2]` Add missing testLocationResults for `xit` and `fit`([#6482](https://github.com/facebook/jest/pull/6482))
- `[jest-cli]` Fix unhandled error when a bad revision is provided to `changedSince` ([#7115](https://github.com/facebook/jest/pull/7115))
- `[jest-config]` Moved dynamically assigned `cwd` from `jest-cli` to default configuration in `jest-config` ([#7146](https://github.com/facebook/jest/pull/7146))
- `[jest-config]` Fix `getMaxWorkers` on termux ([#7154](https://github.com/facebook/jest/pull/7154))
Expand Down
37 changes: 32 additions & 5 deletions e2e/__tests__/location_in_results.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ it('defaults to null for location', () => {

const assertions = result.testResults[0].assertionResults;
expect(result.success).toBe(true);
expect(result.numTotalTests).toBe(2);
expect(result.numTotalTests).toBe(6);
expect(assertions[0].location).toBeNull();
expect(assertions[1].location).toBeNull();
expect(assertions[2].location).toBeNull();
expect(assertions[3].location).toBeNull();
expect(assertions[4].location).toBeNull();
expect(assertions[5].location).toBeNull();
});

it('adds correct location info when provided with flag', () => {
Expand All @@ -28,13 +32,36 @@ it('adds correct location info when provided with flag', () => {

const assertions = result.testResults[0].assertionResults;
expect(result.success).toBe(true);
expect(result.numTotalTests).toBe(2);
expect(assertions[0].location).toEqual({column: 1, line: 10});
expect(result.numTotalTests).toBe(6);
expect(assertions[0].location).toEqual({
column: 1,
line: 12,
});

expect(assertions[1].location).toEqual({
column: 1,
line: 16,
});

expect(assertions[2].location).toEqual({
column: 1,
line: 20,
});

// Technically the column should be 3, but callsites is not correct.
// jest-circus uses stack-utils + asyncErrors which resolves this.
expect(assertions[1].location).toEqual({
expect(assertions[3].location).toEqual({
column: isJestCircusRun() ? 3 : 2,
line: 25,
});

expect(assertions[4].location).toEqual({
column: isJestCircusRun() ? 3 : 2,
line: 29,
});

expect(assertions[5].location).toEqual({
column: isJestCircusRun() ? 3 : 2,
line: 15,
line: 33,
});
});
22 changes: 20 additions & 2 deletions e2e/location-in-results/__tests__/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,30 @@
// This file is missing 'use strict' to force babel into doing something
// as we have `transform-strict-mode`

it('no ancestors', () => {
/* eslint jest/no-focused-tests: 0 */

it('it no ancestors', () => {
expect(true).toBeTruthy();
});

xit('xit no ancestors', () => {
expect(true).toBeTruthy();
});

fit('fit no ancestors', () => {
expect(true).toBeTruthy();
});

describe('nested', () => {
it('also works', () => {
it('it nested', () => {
expect(true).toBeTruthy();
});

xit('xit nested', () => {
expect(true).toBeTruthy();
});

fit('fit nested', () => {
expect(true).toBeTruthy();
});
});
20 changes: 20 additions & 0 deletions packages/jest-jasmine2/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,26 @@ async function jasmine2(

return it;
};

const originalXit = environment.global.xit;
environment.global.xit = (...args) => {
const stack = getCallsite(1, runtime.getSourceMaps());
const xit = originalXit(...args);

xit.result.__callsite = stack;

return xit;
};

const originalFit = environment.global.fit;
environment.global.fit = (...args) => {
const stack = getCallsite(1, runtime.getSourceMaps());
const fit = originalFit(...args);

fit.result.__callsite = stack;

return fit;
};
}

jasmineAsyncInstall(environment.global);
Expand Down