diff --git a/appveyor.yml b/appveyor.yml index 175be2e51548..3fd5a3de0f7b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -16,7 +16,7 @@ test_script: # commented out. Jest complains that obsolete snapshot files exist, so the # "-u" will just delete those snapshots when running in the AppVeyor run, # instead of failing the build. - - npm run jest -- -u + - npm run jest -- -u --color # Don't actually build. build: off diff --git a/integration_tests/__tests__/babel-plugin-jest-hoist-test.js b/integration_tests/__tests__/babel-plugin-jest-hoist-test.js index 0303127185ad..1525d360715d 100644 --- a/integration_tests/__tests__/babel-plugin-jest-hoist-test.js +++ b/integration_tests/__tests__/babel-plugin-jest-hoist-test.js @@ -12,14 +12,19 @@ const {linkJestPackage, run} = require('../utils'); const path = require('path'); const runJest = require('../runJest'); +const skipOnWindows = require('jest-util/build/skipOnWindows'); const DIR = path.resolve(__dirname, '..', 'babel-plugin-jest-hoist'); -beforeEach(() => { - run('npm i', DIR); - linkJestPackage('babel-plugin-jest-hoist', DIR); - linkJestPackage('babel-jest', DIR); -}); +skipOnWindows.suite(); + +if (process.platform !== 'win32') { + beforeEach(() => { + run('npm i', DIR); + linkJestPackage('babel-plugin-jest-hoist', DIR); + linkJestPackage('babel-jest', DIR); + }); +} it('sucessfully runs the tests inside `babel-plugin-jest-hoist/`', () => { const {json} = runJest.json(DIR, ['--no-cache']); diff --git a/integration_tests/__tests__/config-test.js b/integration_tests/__tests__/config-test.js index dbf888f25f66..727a1e3061c8 100644 --- a/integration_tests/__tests__/config-test.js +++ b/integration_tests/__tests__/config-test.js @@ -10,6 +10,9 @@ 'use strict'; const runJest = require('../runJest'); +const skipOnWindows = require('jest-util/build/skipOnWindows'); + +skipOnWindows.suite(); test('config as JSON', () => { const result = runJest('verbose_reporter', [ diff --git a/integration_tests/__tests__/console-test.js b/integration_tests/__tests__/console-test.js index e3b6c9df7a0a..9b9b681b8582 100644 --- a/integration_tests/__tests__/console-test.js +++ b/integration_tests/__tests__/console-test.js @@ -10,6 +10,9 @@ 'use strict'; const runJest = require('../runJest'); +const skipOnWindows = require('jest-util/build/skipOnWindows'); + +skipOnWindows.suite(); test('console printing', () => { const result = runJest('console'); diff --git a/integration_tests/__tests__/coverage_report-test.js b/integration_tests/__tests__/coverage_report-test.js index ea414f67dfee..81f2a8b38a16 100644 --- a/integration_tests/__tests__/coverage_report-test.js +++ b/integration_tests/__tests__/coverage_report-test.js @@ -13,10 +13,15 @@ const {linkJestPackage} = require('../utils'); const runJest = require('../runJest'); const fs = require('fs'); const path = require('path'); +const skipOnWindows = require('jest-util/build/skipOnWindows'); const DIR = path.resolve(__dirname, '../coverage_report'); -beforeEach(() => linkJestPackage('babel-jest', DIR)); +if (process.platform !== 'win32') { + beforeEach(() => linkJestPackage('babel-jest', DIR)); +} + +skipOnWindows.suite(); test('outputs coverage report', () => { const {stdout, status} = runJest(DIR, ['--no-cache', '--coverage']); diff --git a/integration_tests/__tests__/debug-test.js b/integration_tests/__tests__/debug-test.js index 034857a2d224..564cddd72961 100644 --- a/integration_tests/__tests__/debug-test.js +++ b/integration_tests/__tests__/debug-test.js @@ -11,12 +11,17 @@ const {linkJestPackage} = require('../utils'); const path = require('path'); const runJest = require('../runJest'); +const skipOnWindows = require('jest-util/build/skipOnWindows'); describe('jest --debug', () => { + skipOnWindows.suite(); + const dir = path.resolve(__dirname, '..', 'verbose_reporter'); beforeEach(() => { - linkJestPackage('babel-jest', dir); + if (process.platform !== 'win32') { + linkJestPackage('babel-jest', dir); + } }); it('outputs debugging info before running the test', () => { diff --git a/integration_tests/__tests__/empty_suite_error-test.js b/integration_tests/__tests__/empty_suite_error-test.js index 0798f7072bee..08c80e4589b1 100644 --- a/integration_tests/__tests__/empty_suite_error-test.js +++ b/integration_tests/__tests__/empty_suite_error-test.js @@ -10,10 +10,13 @@ const path = require('path'); const runJest = require('../runJest'); +const skipOnWindows = require('jest-util/build/skipOnWindows'); const DIR = path.resolve(__dirname, '../empty_suite_error'); describe('JSON Reporter', () => { + skipOnWindows.suite(); + it('fails the test suite if it contains no tests', () => { const result = runJest(DIR, []); const stderr = result.stderr.toString(); diff --git a/integration_tests/__tests__/env-test.js b/integration_tests/__tests__/env-test.js index 2e2528710e05..912201416d0b 100644 --- a/integration_tests/__tests__/env-test.js +++ b/integration_tests/__tests__/env-test.js @@ -10,10 +10,12 @@ 'use strict'; const runJest = require('../runJest'); +const skipOnWindows = require('jest-util/build/skipOnWindows'); const getLog = result => result.stdout.toString().split('\n')[1].trim(); describe('Environment override', () => { + skipOnWindows.suite(); it('uses jsdom when specified', () => { const result = runJest('env-test', ['--env=jsdom']); diff --git a/integration_tests/__tests__/failures-test.js b/integration_tests/__tests__/failures-test.js index cf09e3cd7a30..a86b76444bf8 100644 --- a/integration_tests/__tests__/failures-test.js +++ b/integration_tests/__tests__/failures-test.js @@ -10,9 +10,12 @@ const path = require('path'); const runJest = require('../runJest'); +const skipOnWindows = require('jest-util/build/skipOnWindows'); const dir = path.resolve(__dirname, '../failures'); +skipOnWindows.suite(); + test('throwing not Error objects', () => { let stderr; stderr = runJest(dir, ['throw-number-test.js']).stderr; diff --git a/integration_tests/__tests__/jasmine_async-test.js b/integration_tests/__tests__/jasmine_async-test.js index 5ac9abcd6673..7583535f4632 100644 --- a/integration_tests/__tests__/jasmine_async-test.js +++ b/integration_tests/__tests__/jasmine_async-test.js @@ -9,8 +9,11 @@ 'use strict'; const runJest = require('../runJest'); +const skipOnWindows = require('jest-util/build/skipOnWindows'); describe('async jasmine', () => { + skipOnWindows.suite(); + it('works with beforeAll', () => { const result = runJest.json( 'jasmine_async', diff --git a/integration_tests/__tests__/json_reporter-test.js b/integration_tests/__tests__/json_reporter-test.js index 4f8ab1c887b9..b3b96b9c940e 100644 --- a/integration_tests/__tests__/json_reporter-test.js +++ b/integration_tests/__tests__/json_reporter-test.js @@ -8,8 +8,11 @@ 'use strict'; const runJest = require('../runJest'); +const skipOnWindows = require('jest-util/build/skipOnWindows'); describe('JSON Reporter', () => { + skipOnWindows.suite(); + it('outputs coverage report', () => { const result = runJest('json_reporter', ['--json']); const stdout = result.stdout.toString(); diff --git a/integration_tests/__tests__/no-test-found-test.js b/integration_tests/__tests__/no-test-found-test.js index 2c7c901c1d83..2f11cf5f9d07 100644 --- a/integration_tests/__tests__/no-test-found-test.js +++ b/integration_tests/__tests__/no-test-found-test.js @@ -10,8 +10,11 @@ 'use strict'; const runJest = require('../runJest'); +const skipOnWindows = require('jest-util/build/skipOnWindows'); describe('Coverage Report', () => { + skipOnWindows.suite(); + it('outputs coverage report', () => { const result = runJest('coverage_report', ['not-a-valid-test']); const stdout = result.stdout.toString(); diff --git a/integration_tests/__tests__/regex-(char-in-path-test.js b/integration_tests/__tests__/regex-(char-in-path-test.js index 873d4505597f..01def1f33de7 100644 --- a/integration_tests/__tests__/regex-(char-in-path-test.js +++ b/integration_tests/__tests__/regex-(char-in-path-test.js @@ -10,8 +10,11 @@ 'use strict'; const runJest = require('../runJest'); +const skipOnWindows = require('jest-util/build/skipOnWindows'); describe('Regex Char In Path', () => { + skipOnWindows.suite(); + it('parses paths containing regex chars correctly', () => { const {json} = runJest.json('regex-(char-in-path', []); diff --git a/integration_tests/__tests__/set-immediate-test.js b/integration_tests/__tests__/set-immediate-test.js index d6792095da10..2f733b1039ac 100644 --- a/integration_tests/__tests__/set-immediate-test.js +++ b/integration_tests/__tests__/set-immediate-test.js @@ -10,6 +10,9 @@ 'use strict'; const runJest = require('../runJest'); +const skipOnWindows = require('jest-util/build/skipOnWindows'); + +skipOnWindows.suite(); test('setImmediate', () => { const result = runJest('set_immediate', ['--verbose']); diff --git a/integration_tests/__tests__/setup_test_framework_script_file_cli_config-test.js b/integration_tests/__tests__/setup_test_framework_script_file_cli_config-test.js index bee129c1480e..86b4e04ffb66 100644 --- a/integration_tests/__tests__/setup_test_framework_script_file_cli_config-test.js +++ b/integration_tests/__tests__/setup_test_framework_script_file_cli_config-test.js @@ -8,8 +8,11 @@ 'use strict'; const runJest = require('../runJest'); +const skipOnWindows = require('jest-util/build/skipOnWindows'); describe('--setupTestFrameworkScriptFile setup.js', () => { + skipOnWindows.suite(); + it('requires a setup file before each file in the suite', () => { const result = runJest.json('setup_test_framework_script_file_cli_config', [ '--setupTestFrameworkScriptFile', diff --git a/integration_tests/__tests__/snapshot-test.js b/integration_tests/__tests__/snapshot-test.js index 3a1bd981de95..71b4323f47f8 100644 --- a/integration_tests/__tests__/snapshot-test.js +++ b/integration_tests/__tests__/snapshot-test.js @@ -12,6 +12,7 @@ const fs = require('fs'); const path = require('path'); const runJest = require('../runJest'); +const skipOnWindows = require('jest-util/build/skipOnWindows'); const emptyTest = 'describe("", () => {it("", () => {})})'; const snapshotDir = @@ -54,6 +55,7 @@ const getSnapshotOfCopy = () => { }; describe('Snapshot', () => { + skipOnWindows.suite(); const cleanup = () => { [ diff --git a/integration_tests/__tests__/stack_trace-test.js b/integration_tests/__tests__/stack_trace-test.js index 284ee8e0d5a0..7297fa3b6948 100644 --- a/integration_tests/__tests__/stack_trace-test.js +++ b/integration_tests/__tests__/stack_trace-test.js @@ -8,8 +8,10 @@ 'use strict'; const runJest = require('../runJest'); +const skipOnWindows = require('jest-util/build/skipOnWindows'); describe('Stack Trace', () => { + skipOnWindows.suite(); it('prints a stack trace for runtime errors', () => { const result = runJest('stack_trace', ['runtime-error-test.js']); diff --git a/integration_tests/__tests__/testcheck-test.js b/integration_tests/__tests__/testcheck-test.js index e6a04312095f..5669d3d7d36a 100644 --- a/integration_tests/__tests__/testcheck-test.js +++ b/integration_tests/__tests__/testcheck-test.js @@ -9,8 +9,11 @@ 'use strict'; const runJest = require('../runJest'); +const skipOnWindows = require('jest-util/build/skipOnWindows'); describe('testcheck', () => { + skipOnWindows.suite(); + it('works', () => { const result = runJest.json('testcheck', ['testcheck-test.js']); const json = result.json; diff --git a/integration_tests/__tests__/transform-test.js b/integration_tests/__tests__/transform-test.js index 421c2592c8db..d01d5db71ec0 100644 --- a/integration_tests/__tests__/transform-test.js +++ b/integration_tests/__tests__/transform-test.js @@ -11,13 +11,17 @@ const {linkJestPackage, run} = require('../utils'); const path = require('path'); const runJest = require('../runJest'); +const skipOnWindows = require('jest-util/build/skipOnWindows'); describe('babel-jest', () => { + skipOnWindows.suite(); const dir = path.resolve(__dirname, '..', 'transform/babel-jest'); beforeEach(() => { - run('npm install', dir); - linkJestPackage('babel-jest', dir); + if (process.platform !== 'win32') { + run('npm install', dir); + linkJestPackage('babel-jest', dir); + } }); it('runs transpiled code', () => { diff --git a/integration_tests/__tests__/typescript-coverage-test.js b/integration_tests/__tests__/typescript-coverage-test.js index 5a529fe29b1e..8854a247f8e9 100644 --- a/integration_tests/__tests__/typescript-coverage-test.js +++ b/integration_tests/__tests__/typescript-coverage-test.js @@ -11,6 +11,9 @@ const {run} = require('../utils'); const path = require('path'); const runJest = require('../runJest'); +const skipOnWindows = require('jest-util/build/skipOnWindows'); + +skipOnWindows.suite(); it('instruments and collects coverage for typescript files', () => { const dir = path.resolve(__dirname, '../typescript-coverage'); diff --git a/integration_tests/__tests__/verbose-test.js b/integration_tests/__tests__/verbose-test.js index bc10ff48688a..d4c5e24318fb 100644 --- a/integration_tests/__tests__/verbose-test.js +++ b/integration_tests/__tests__/verbose-test.js @@ -10,6 +10,9 @@ 'use strict'; const runJest = require('../runJest'); +const skipOnWindows = require('jest-util/build/skipOnWindows'); + +skipOnWindows.suite(); test('Verbose Reporter', () => { const result = runJest('verbose_reporter'); diff --git a/packages/jest-changed-files/src/__tests__/git-test.js b/packages/jest-changed-files/src/__tests__/git-test.js index 9f77c06374ae..2634b9ac6193 100644 --- a/packages/jest-changed-files/src/__tests__/git-test.js +++ b/packages/jest-changed-files/src/__tests__/git-test.js @@ -43,6 +43,10 @@ describe('git', () => { childProcess.spawnSync('git', ['init', tmpdir]); return git.isGitRepository(tmpdir).then(res => { + if (process.platform === 'win32') { + // Git port on Win32 returns paths with "/" rather than "\" + res = res.replace(/\//g, '\\'); + } expect(res).toContain(tmpdir); }); }); diff --git a/packages/jest-cli/src/__tests__/SearchSource-test.js b/packages/jest-cli/src/__tests__/SearchSource-test.js index aa6468939591..88783677d932 100644 --- a/packages/jest-cli/src/__tests__/SearchSource-test.js +++ b/packages/jest-cli/src/__tests__/SearchSource-test.js @@ -12,6 +12,7 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 15000; const path = require('path'); +const skipOnWindows = require('jest-util/build/skipOnWindows'); const rootDir = path.resolve(__dirname, 'test_root'); const testRegex = path.sep + '__testtests__' + path.sep; @@ -21,6 +22,8 @@ let findMatchingTests; let normalizeConfig; describe('SearchSource', () => { + skipOnWindows.suite(); + const name = 'SearchSource'; let Runtime; let SearchSource; diff --git a/packages/jest-haste-map/src/__tests__/index-test.js b/packages/jest-haste-map/src/__tests__/index-test.js index 64b6f6dbe896..99f3895d46d8 100644 --- a/packages/jest-haste-map/src/__tests__/index-test.js +++ b/packages/jest-haste-map/src/__tests__/index-test.js @@ -9,6 +9,8 @@ */ 'use strict'; +const skipOnWindows = require('jest-util/build/skipOnWindows'); + jest.mock('child_process', () => ({ // If this does not throw, we'll use the (mocked) watchman crawler execSync() {}, @@ -59,6 +61,7 @@ let workerFarmMock; let writeFileSync; describe('HasteMap', () => { + skipOnWindows.suite(); beforeEach(() => { jest.resetModules(); diff --git a/packages/jest-haste-map/src/__tests__/worker-test.js b/packages/jest-haste-map/src/__tests__/worker-test.js index 20c813e3672a..835835e21ce5 100644 --- a/packages/jest-haste-map/src/__tests__/worker-test.js +++ b/packages/jest-haste-map/src/__tests__/worker-test.js @@ -10,6 +10,7 @@ 'use strict'; const H = require('../constants'); +const skipOnWindows = require('jest-util/build/skipOnWindows'); const worker = require('../worker'); const fs = require('graceful-fs'); @@ -21,6 +22,7 @@ let readFileSync; let workerError; describe('worker', () => { + skipOnWindows.suite(); beforeEach(() => { mockFs = { diff --git a/packages/jest-haste-map/src/crawlers/__tests__/node-test.js b/packages/jest-haste-map/src/crawlers/__tests__/node-test.js index 5d366daa76b7..5069b06d731d 100644 --- a/packages/jest-haste-map/src/crawlers/__tests__/node-test.js +++ b/packages/jest-haste-map/src/crawlers/__tests__/node-test.js @@ -9,6 +9,8 @@ */ 'use strict'; +const skipOnWindows = require('jest-util/build/skipOnWindows'); + jest.mock('child_process', () => ({ spawn: jest.fn((cmd, args) => { let closeCallback; @@ -67,6 +69,7 @@ let nodeCrawl; let childProcess; describe('node crawler', () => { + skipOnWindows.suite(); beforeEach(() => { jest.resetModules(); diff --git a/packages/jest-haste-map/src/crawlers/__tests__/watchman-test.js b/packages/jest-haste-map/src/crawlers/__tests__/watchman-test.js index 1dc9dbf54cf6..0a8ec9f84251 100644 --- a/packages/jest-haste-map/src/crawlers/__tests__/watchman-test.js +++ b/packages/jest-haste-map/src/crawlers/__tests__/watchman-test.js @@ -9,6 +9,8 @@ */ 'use strict'; +const skipOnWindows = require('jest-util/build/skipOnWindows'); + jest.mock('fb-watchman', () => { const Client = jest.fn(); Client.prototype.command = jest.fn((args, callback) => { @@ -30,6 +32,7 @@ let mockResponse; let mockFiles; describe('watchman watch', () => { + skipOnWindows.suite(); beforeEach(() => { watchmanCrawl = require('../watchman'); diff --git a/packages/jest-matchers/src/__tests__/toThrowMatchers-test.js b/packages/jest-matchers/src/__tests__/toThrowMatchers-test.js index 57a93f936f8c..ac182278ead3 100644 --- a/packages/jest-matchers/src/__tests__/toThrowMatchers-test.js +++ b/packages/jest-matchers/src/__tests__/toThrowMatchers-test.js @@ -12,6 +12,7 @@ const jestExpect = require('../').expect; const matchErrorSnapshot = require('./_matchErrorSnapshot'); +const skipOnWindows = require('jest-util/build/skipOnWindows'); // Custom Error class because node versions have different stack trace strings. class Error { @@ -27,6 +28,7 @@ class Error { ['toThrowError', 'toThrow'].forEach(toThrow => { describe('.' + toThrow + '()', () => { + skipOnWindows.suite(); class Err extends Error {} class Err2 extends Error {} diff --git a/packages/jest-repl/src/__tests__/jest-repl-test.js b/packages/jest-repl/src/__tests__/jest-repl-test.js index bbec467bdf55..0605a8f0a980 100644 --- a/packages/jest-repl/src/__tests__/jest-repl-test.js +++ b/packages/jest-repl/src/__tests__/jest-repl-test.js @@ -9,12 +9,15 @@ */ 'use strict'; +const skipOnWindows = require('jest-util/build/skipOnWindows'); const spawnSync = require('child_process').spawnSync; const path = require('path'); const JEST_RUNTIME = path.resolve(__dirname, '../../bin/jest-repl.js'); describe('Repl', () => { + skipOnWindows.suite(); + describe('cli', () => { it('runs without errors', () => { const output = spawnSync(JEST_RUNTIME, [], { diff --git a/packages/jest-runtime/src/__tests__/Runtime-cli-test.js b/packages/jest-runtime/src/__tests__/Runtime-cli-test.js index 7af90b3dabd3..3b846f372946 100644 --- a/packages/jest-runtime/src/__tests__/Runtime-cli-test.js +++ b/packages/jest-runtime/src/__tests__/Runtime-cli-test.js @@ -9,6 +9,7 @@ */ 'use strict'; +const skipOnWindows = require('jest-util/build/skipOnWindows'); const spawnSync = require('child_process').spawnSync; const path = require('path'); @@ -21,6 +22,8 @@ const run = args => spawnSync(JEST_RUNTIME, args, { }); describe('Runtime', () => { + skipOnWindows.suite(); + describe('cli', () => { it('fails with no path', () => { const expectedOutput = diff --git a/packages/jest-runtime/src/__tests__/transform-test.js b/packages/jest-runtime/src/__tests__/transform-test.js index 64f4936bc12b..4a96953f18e8 100644 --- a/packages/jest-runtime/src/__tests__/transform-test.js +++ b/packages/jest-runtime/src/__tests__/transform-test.js @@ -9,6 +9,8 @@ */ 'use strict'; +const skipOnWindows = require('jest-util/build/skipOnWindows'); + jest .mock('graceful-fs') .mock('jest-file-exists') @@ -163,6 +165,9 @@ describe('transform', () => { }); it('reads values from the cache', () => { + if (skipOnWindows.test()) { + return; + } const transformConfig = Object.assign(config, { scriptPreprocessor: 'test-preprocessor', }); diff --git a/packages/jest-util/src/__tests__/FakeTimers-test.js b/packages/jest-util/src/__tests__/FakeTimers-test.js index 1d0641ad89df..262bb6460f08 100644 --- a/packages/jest-util/src/__tests__/FakeTimers-test.js +++ b/packages/jest-util/src/__tests__/FakeTimers-test.js @@ -9,6 +9,8 @@ */ 'use strict'; +const skipOnWindows = require('jest-util/build/skipOnWindows'); + describe('FakeTimers', () => { let FakeTimers; @@ -326,6 +328,9 @@ describe('FakeTimers', () => { }); it('warns when trying to advance timers while real timers are used', () => { + if (skipOnWindows.test()) { + return; + } const consoleWarn = console.warn; console.warn = jest.fn(); const timers = new FakeTimers(global, {rootDir: __dirname}); diff --git a/packages/jest-util/src/skipOnWindows.js b/packages/jest-util/src/skipOnWindows.js new file mode 100644 index 000000000000..3e0c8565a5cd --- /dev/null +++ b/packages/jest-util/src/skipOnWindows.js @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @flow + */ +'use strict'; + +const skipOnWindows = { + suite() { + if (process.platform === 'win32') { + // $FlowFixMe + fit('does not work on Windows', () => { + console.warn('[SKIP] Does not work on Windows'); + }); + } + }, + + test() { + if (process.platform === 'win32') { + console.warn('[SKIP] Does not work on Windows'); + return true; + } + return false; + } +} + +module.exports = skipOnWindows;