diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 000000000000..c8d0c18c87a6 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,23 @@ +environment: + matrix: + #- nodejs_version: "4" + - nodejs_version: "6" + +install: + - ps: Install-Product node $env:nodejs_version x64 + - npm i -g npm@latest + - node --version + - npm --version + - npm install + +test_script: + - npm run build + # Some snapshot tests don't currently work on Windows, so the tests are + # 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. Note that this means that all snapshot tests + # WILL ALWAYS PASS, as it updates the snapshots. + - 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..98846bd3fbc6 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('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..31d046166a5b 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('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..8fa543a9463d 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('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..86f47d163f41 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('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..5c6ac611a982 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('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..a0330a13da0f 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('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..b596c1416186 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('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..6c59100354a1 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('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..2ebab2ec1a69 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('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..2c51238c66ce 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('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..4ef9dbaccd3d 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('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..b91bdced0049 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('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..166a16d6cb01 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('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..f2c889675737 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('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..f94869745087 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('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..85546b160fdb 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('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..62d0f2f075bd 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('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..083cf3a5c45f 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('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..966a0f5b9083 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('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..057ab4ccdfec 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('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..7b6730bb692e 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('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..97edb90fb0f0 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('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..2f7451b274a8 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('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..fb360b9ee8ab 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('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..13668978c070 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('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..f8a0a2830ad5 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('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..ee35835760e5 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('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..0359823bd249 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('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..de491a846098 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('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..d044334acf0e 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('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/scripts/skipOnWindows.js b/scripts/skipOnWindows.js new file mode 100644 index 000000000000..cdd6e57edaa1 --- /dev/null +++ b/scripts/skipOnWindows.js @@ -0,0 +1,32 @@ +/** + * 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 + * @providesModule skipOnWindows + */ +'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;