-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
test: allow more tests to run on windows #10351
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
*/ | ||
|
||
import {wrap} from 'jest-snapshot-serializer-raw'; | ||
import {onNodeVersions, skipSuiteOnWindows} from '@jest/test-utils'; | ||
import {onNodeVersions} from '@jest/test-utils'; | ||
import runJest, {runContinuous} from '../runJest'; | ||
|
||
try { | ||
|
@@ -72,9 +72,13 @@ it('does not report promises', () => { | |
}); | ||
|
||
describe('notify', () => { | ||
skipSuiteOnWindows(); | ||
|
||
it('does not report --notify flag', () => { | ||
if (process.platform === 'win32') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this the same as the skip? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, as the skip causes all tests in the file to be skipped, but this is the only one that actually fails. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the only test aside from the yarn pnp one that is now being skipped on Windows 🎉 Open to ideas on if anything can be done to eliminate it - I suspect it represents an actual "bug" (/ maybe just something that can't be supported?) |
||
console.warn('[SKIP] Does not work on Windows'); | ||
|
||
return; | ||
} | ||
|
||
// The test here is basically that it exits cleanly without reporting anything (does not need `until`) | ||
const {stderr} = runJest('detect-open-handles', ['notify', '--notify']); | ||
const textAfterTest = getTextAfterTest(stderr); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,12 +9,10 @@ import {tmpdir} from 'os'; | |
import * as path from 'path'; | ||
import {wrap} from 'jest-snapshot-serializer-raw'; | ||
import {findRepos, getChangedFilesForRoots} from 'jest-changed-files'; | ||
import {skipSuiteOnWindows} from '@jest/test-utils'; | ||
import slash from 'slash'; | ||
import {cleanup, run, testIfHg, writeFiles} from '../Utils'; | ||
import runJest from '../runJest'; | ||
|
||
skipSuiteOnWindows(); | ||
|
||
const DIR = path.resolve(tmpdir(), 'jest-changed-files-test-dir'); | ||
|
||
const GIT = 'git -c user.name=jest_test -c [email protected]'; | ||
|
@@ -54,8 +52,12 @@ testIfHg('gets hg SCM roots and dedupes them', async () => { | |
// NOTE: This test can break if you have a .hg repo initialized inside your | ||
// os tmp directory. | ||
expect(hgRepos).toHaveLength(2); | ||
expect(hgRepos[0]).toMatch(/\/jest-changed-files-test-dir\/first-repo\/?$/); | ||
expect(hgRepos[1]).toMatch(/\/jest-changed-files-test-dir\/second-repo\/?$/); | ||
expect(slash(hgRepos[0])).toMatch( | ||
/\/jest-changed-files-test-dir\/first-repo\/?$/, | ||
); | ||
expect(slash(hgRepos[1])).toMatch( | ||
/\/jest-changed-files-test-dir\/second-repo\/?$/, | ||
); | ||
}); | ||
|
||
test('gets git SCM roots and dedupes them', async () => { | ||
|
@@ -88,8 +90,12 @@ test('gets git SCM roots and dedupes them', async () => { | |
// NOTE: This test can break if you have a .git repo initialized inside your | ||
// os tmp directory. | ||
expect(gitRepos).toHaveLength(2); | ||
expect(gitRepos[0]).toMatch(/\/jest-changed-files-test-dir\/first-repo\/?$/); | ||
expect(gitRepos[1]).toMatch(/\/jest-changed-files-test-dir\/second-repo\/?$/); | ||
expect(slash(gitRepos[0])).toMatch( | ||
/\/jest-changed-files-test-dir\/first-repo\/?$/, | ||
); | ||
expect(slash(gitRepos[1])).toMatch( | ||
/\/jest-changed-files-test-dir\/second-repo\/?$/, | ||
); | ||
}); | ||
|
||
testIfHg('gets mixed git and hg SCM roots and dedupes them', async () => { | ||
|
@@ -121,8 +127,12 @@ testIfHg('gets mixed git and hg SCM roots and dedupes them', async () => { | |
// inside your os tmp directory. | ||
expect(gitRepos).toHaveLength(1); | ||
expect(hgRepos).toHaveLength(1); | ||
expect(gitRepos[0]).toMatch(/\/jest-changed-files-test-dir\/first-repo\/?$/); | ||
expect(hgRepos[0]).toMatch(/\/jest-changed-files-test-dir\/second-repo\/?$/); | ||
expect(slash(gitRepos[0])).toMatch( | ||
/\/jest-changed-files-test-dir\/first-repo\/?$/, | ||
); | ||
expect(slash(hgRepos[0])).toMatch( | ||
/\/jest-changed-files-test-dir\/second-repo\/?$/, | ||
); | ||
}); | ||
|
||
test('gets changed files for git', async () => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we normalize the output of jest instead of normalizing in the test itself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, yes but I don't know how much work that'll involve.
However, I don't know if thats a good idea from UX POV, as
jest
is implicitly normalizing the input - we pass in./foo/bar.spec.js
, which is a Linux style file path (it's actually probably node doing the normalizing, but the result is the same).By outputting the actual OS-specific file path that was used, users can see that it doesn't matter if they pass in Linux file paths; where as if we normalised them in the output here, personally I'd look at that and think "oh maybe Jest isn't finding my test file because it's using the Linux file path" (especially since copying & pasting the file path into Windows would cause an error, as iirc Powershell, CMD, and Explorer all expect forward slashes).