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

Jest CLI --testLocationInResults doesn't work with fit/xit test #6453

Closed
svenliebig opened this issue Jun 12, 2018 · 5 comments · Fixed by #6482
Closed

Jest CLI --testLocationInResults doesn't work with fit/xit test #6453

svenliebig opened this issue Jun 12, 2018 · 5 comments · Fixed by #6482

Comments

@svenliebig
Copy link
Contributor

While executing this command:

node <pathToMyProject>\node_modules\jest\bin\jest -c=<pathToMyProject>\package.json ./test/myTest.test.jsx --json --testLocationInResults

on this file:

describe(`test`, () => {
    it("1 + 2 is 3", () => {
        expect(1 + 2).toBe(3)
    })
})

I get the Result:

{
	"numFailedTestSuites": 0,
	"numFailedTests": 0,
	"numPassedTestSuites": 1,
	"numPassedTests": 1,
	"numPendingTestSuites": 0,
	"numPendingTests": 0,
	"numRuntimeErrorTestSuites": 0,
	"numTotalTestSuites": 1,
	"numTotalTests": 1,
	"openHandles": [],
	"snapshot": {
		"added": 0,
		"didUpdate": false,
		"failure": false,
		"filesAdded": 0,
		"filesRemoved": 0,
		"filesUnmatched": 0,
		"filesUpdated": 0,
		"matched": 0,
		"total": 0,
		"unchecked": 0,
		"uncheckedKeysByFile": [],
		"unmatched": 0,
		"updated": 0
	},
	"startTime": 1528841599675,
	"success": true,
	"testResults": [{
		"assertionResults": [{
			"ancestorTitles": ["test"],
			"failureMessages": [],
			"fullName": "test 1 + 2 is 3",
			"location": {
				"column": 5,
				"line": 2
			},
			"status": "passed",
			"title": "1 + 2 is 3"
		}],
		"endTime": 1528841600492,
		"message": "",
		"name": "<pathToMyProject>\\test\\myTest.test.jsx",
		"startTime": 1528841600207,
		"status": "passed",
		"summary": ""
	}],
	"wasInterrupted": false
}

When executing the same command:

node <pathToMyProject>\node_modules\jest\bin\jest -c=<pathToMyProject>\package.json ./test/myTest.test.jsx --json --testLocationInResults

on the file with the same test, including a fit instead of an ìt` test:

describe(`test`, () => {
    fit("1 + 2 is 3", () => {
        expect(1 + 2).toBe(3)
    })
})

I get this Result:

{
	"numFailedTestSuites": 0,
	"numFailedTests": 0,
	"numPassedTestSuites": 1,
	"numPassedTests": 1,
	"numPendingTestSuites": 0,
	"numPendingTests": 0,
	"numRuntimeErrorTestSuites": 0,
	"numTotalTestSuites": 1,
	"numTotalTests": 1,
	"openHandles": [],
	"snapshot": {
		"added": 0,
		"didUpdate": false,
		"failure": false,
		"filesAdded": 0,
		"filesRemoved": 0,
		"filesUnmatched": 0,
		"filesUpdated": 0,
		"matched": 0,
		"total": 0,
		"unchecked": 0,
		"uncheckedKeysByFile": [],
		"unmatched": 0,
		"updated": 0
	},
	"startTime": 1528841987889,
	"success": true,
	"testResults": [{
		"assertionResults": [{
			"ancestorTitles": ["test"],
			"failureMessages": [],
			"fullName": "test 1 + 2 is 3",
			"location": null,
			"status": "passed",
			"title": "1 + 2 is 3"
		}],
		"endTime": 1528841988694,
		"message": "",
		"name": "e:\\workspace\\time\\web\\test\\Components dir\\myTest.test.jsx",
		"startTime": 1528841988419,
		"status": "passed",
		"summary": ""
	}],
	"wasInterrupted": false
}

Somehow the testResult[0].assertionResults[0].location disappears when i focus the specific test. If i have multiple test cases like this:

describe(`test`, () => {
	fit("1 + 2 is 3", () => {
		expect(1 + 2).toBe(3)
	})
	
	it("3 + 4 is 5", () => {
		expect(3 + 4).toBe(7)
	})
})

The JSON result only excludes the location property of the focus test:

{
	"numFailedTestSuites": 0,
	"numFailedTests": 0,
	"numPassedTestSuites": 1,
	"numPassedTests": 1,
	"numPendingTestSuites": 0,
	"numPendingTests": 1,
	"numRuntimeErrorTestSuites": 0,
	"numTotalTestSuites": 1,
	"numTotalTests": 2,
	"openHandles": [],
	"snapshot": {
		"added": 0,
		"didUpdate": false,
		"failure": false,
		"filesAdded": 0,
		"filesRemoved": 0,
		"filesUnmatched": 0,
		"filesUpdated": 0,
		"matched": 0,
		"total": 0,
		"unchecked": 0,
		"uncheckedKeysByFile": [],
		"unmatched": 0,
		"updated": 0
	},
	"startTime": 1528842131976,
	"success": true,
	"testResults": [{
		"assertionResults": [{
			"ancestorTitles": ["test"],
			"failureMessages": [],
			"fullName": "test 1 + 2 is 3",
			"location": null,
			"status": "passed",
			"title": "1 + 2 is 3"
		}, {
			"ancestorTitles": ["test"],
			"failureMessages": [],
			"fullName": "test 3 + 4 is 5",
			"location": {
				"column": 2,
				"line": 6
			},
			"status": "pending",
			"title": "3 + 4 is 5"
		}],
		"endTime": 1528842132797,
		"message": "",
		"name": "e:\\workspace\\time\\web\\test\\Components dir\\myTest.test.jsx",
		"startTime": 1528842132506,
		"status": "passed",
		"summary": ""
	}],
	"wasInterrupted": false
}

Same when i exclude on test like this:

describe(`test`, () => {
	it("1 + 2 is 3", () => {
		expect(1 + 2).toBe(3)
	})
	
	xit("3 + 4 is 5", () => {
		expect(3 + 4).toBe(7)
	})
})

The result is also missing the location property of this test:

{
	"numFailedTestSuites": 0,
	"numFailedTests": 0,
	"numPassedTestSuites": 1,
	"numPassedTests": 1,
	"numPendingTestSuites": 0,
	"numPendingTests": 1,
	"numRuntimeErrorTestSuites": 0,
	"numTotalTestSuites": 1,
	"numTotalTests": 2,
	"openHandles": [],
	"snapshot": {
		"added": 0,
		"didUpdate": false,
		"failure": false,
		"filesAdded": 0,
		"filesRemoved": 0,
		"filesUnmatched": 0,
		"filesUpdated": 0,
		"matched": 0,
		"total": 0,
		"unchecked": 0,
		"uncheckedKeysByFile": [],
		"unmatched": 0,
		"updated": 0
	},
	"startTime": 1528842197727,
	"success": true,
	"testResults": [{
		"assertionResults": [{
			"ancestorTitles": ["test"],
			"failureMessages": [],
			"fullName": "test 1 + 2 is 3",
			"location": {
				"column": 2,
				"line": 2
			},
			"status": "passed",
			"title": "1 + 2 is 3"
		}, {
			"ancestorTitles": ["test"],
			"failureMessages": [],
			"fullName": "test 3 + 4 is 5",
			"location": null,
			"status": "pending",
			"title": "3 + 4 is 5"
		}],
		"endTime": 1528842198539,
		"message": "",
		"name": "e:\\workspace\\time\\web\\test\\Components dir\\myTest.test.jsx",
		"startTime": 1528842198253,
		"status": "passed",
		"summary": ""
	}],
	"wasInterrupted": false
}

jest config in the package json:

"jest": {
    "transform": {
      "^.+\\.js$": "babel-jest"
    },
    "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?)$",
    "moduleFileExtensions": [
      "js",
      "jsx"
    ]
  },

Is there something that i am missing in my CLI execution? Or did i found a bug.

@svenliebig svenliebig changed the title Jest CLI --testLocationInResults doesn't work with fit test Jest CLI --testLocationInResults doesn't work with fit/xit test Jun 12, 2018
@SimenB
Copy link
Member

SimenB commented Jun 13, 2018

You found a bug :) Wanna send a PR to fix it?

@svenliebig
Copy link
Contributor Author

I could give it a try on weekend, may i figure out where this comes from. ;)

@SimenB
Copy link
Member

SimenB commented Jun 14, 2018

You can see it added to it (and thus test) here: https://github.com/facebook/jest/blob/9c1c3b1f072175e434943d1eb99d84b4d72ed458/packages/jest-jasmine2/src/index.js#L47-L57

Should figure out some way of sharing it with xit and fit as well

@SimenB
Copy link
Member

SimenB commented Jun 14, 2018

Might consider a refactor to use the stack of the async error, same as in circus, cc @captbaritone

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants