-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
230 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
integration_tests/__tests__/__snapshots__/showConfig-test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`jest --showConfig outputs config info and exits 1`] = ` | ||
{ | ||
"version": "19.0.2", | ||
"framework": "jasmine2", | ||
"config": { | ||
"automock": false, | ||
"bail": false, | ||
"browser": false, | ||
"cacheDirectory": "/tmp/jest", | ||
"clearMocks": false, | ||
"coveragePathIgnorePatterns": [ | ||
"/node_modules/" | ||
], | ||
"coverageReporters": [ | ||
"json", | ||
"text", | ||
"lcov", | ||
"clover" | ||
], | ||
"expand": false, | ||
"globals": {}, | ||
"haste": { | ||
"providesModuleNodeModules": [] | ||
}, | ||
"mapCoverage": false, | ||
"moduleDirectories": [ | ||
"node_modules" | ||
], | ||
"moduleFileExtensions": [ | ||
"js", | ||
"json", | ||
"jsx", | ||
"node" | ||
], | ||
"moduleNameMapper": {}, | ||
"modulePathIgnorePatterns": [], | ||
"noStackTrace": false, | ||
"notify": false, | ||
"preset": null, | ||
"resetMocks": false, | ||
"resetModules": false, | ||
"roots": [ | ||
"/mocked/root/path/jest/integration_tests/verbose_reporter" | ||
], | ||
"snapshotSerializers": [], | ||
"testEnvironment": "/mocked/root/path/jest/packages/jest-environment-node/build/index.js", | ||
"testMatch": [ | ||
"**/__tests__/**/*.js?(x)", | ||
"**/?(*.)(spec|test).js?(x)" | ||
], | ||
"testPathIgnorePatterns": [ | ||
"/node_modules/" | ||
], | ||
"testRegex": "", | ||
"testResultsProcessor": null, | ||
"testURL": "about:blank", | ||
"timers": "real", | ||
"transformIgnorePatterns": [ | ||
"/node_modules/" | ||
], | ||
"useStderr": false, | ||
"verbose": null, | ||
"watch": false, | ||
"rootDir": "/mocked/root/path/jest/integration_tests/verbose_reporter", | ||
"name": "[md5 hash]", | ||
"setupFiles": [ | ||
"/mocked/root/path/jest/node_modules/regenerator-runtime/runtime.js" | ||
], | ||
"testRunner": "/mocked/root/path/jest/packages/jest-jasmine2/build/index.js", | ||
"transform": [ | ||
[ | ||
"^.+\\\\.jsx?$", | ||
"/mocked/root/path/jest/integration_tests/verbose_reporter/node_modules/babel-jest/build/index.js" | ||
] | ||
], | ||
"cache": false, | ||
"watchman": true | ||
} | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const {linkJestPackage} = require('../utils'); | ||
const path = require('path'); | ||
const runJest = require('../runJest'); | ||
const skipOnWindows = require('skipOnWindows'); | ||
|
||
describe('jest --showConfig', () => { | ||
skipOnWindows.suite(); | ||
|
||
const dir = path.resolve(__dirname, '..', 'verbose_reporter'); | ||
|
||
beforeEach(() => { | ||
if (process.platform !== 'win32') { | ||
linkJestPackage('babel-jest', dir); | ||
} | ||
}); | ||
|
||
it('outputs config info and exits', () => { | ||
const root = path.join(__dirname, '..', '..', '..'); | ||
expect.addSnapshotSerializer({ | ||
print: val => val | ||
.replace(new RegExp(root, 'g'), '/mocked/root/path') | ||
.replace(/"name": "(.+)"/, '"name": "[md5 hash]"') | ||
.replace(/"cacheDirectory": "(.+)"/, '"cacheDirectory": "/tmp/jest"'), | ||
test: val => typeof val === 'string', | ||
}); | ||
const {stdout} = runJest(dir, ['--showConfig', '--no-cache']); | ||
expect(stdout).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
packages/jest-editor-support/src/__tests__/Settings-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const ProjectWorkspace = require('../ProjectWorkspace'); | ||
const Settings = require('../Settings'); | ||
const path = require('path'); | ||
|
||
describe('Settings', () => { | ||
it('sets itself up fom the constructor', () => { | ||
const workspace = new ProjectWorkspace('root_path', 'path_to_jest'); | ||
const settings = new Settings(workspace); | ||
expect(settings.workspace).toEqual(workspace); | ||
expect(settings.settings).toEqual(expect.any(Object)); | ||
}); | ||
|
||
it('reads and parses the config', () => { | ||
const jestPath = path.join( | ||
'packages', 'jest', 'node_modules', '.bin', 'jest' | ||
); | ||
const workspace = new ProjectWorkspace('.', jestPath); | ||
const completed = jest.fn(); | ||
const config = {cacheDirectory: '/tmp/jest', name: '[md5 hash]'}; | ||
const json = { | ||
config, | ||
version: '19.0.0', | ||
}; | ||
const buffer = makeBuffer(JSON.stringify(json)); | ||
const settings = new Settings(workspace); | ||
|
||
settings.getConfig(completed); | ||
settings.debugprocess.stdout.emit('data', buffer); | ||
|
||
expect(completed).toHaveBeenCalled(); | ||
expect(settings.jestVersionMajor).toBe(19); | ||
expect(settings.settings).toEqual(config); | ||
}); | ||
}); | ||
|
||
const makeBuffer = (content: string) => { | ||
// Buffer.from is not supported in < Node 5.10 | ||
if (typeof Buffer.from === 'function') { | ||
return Buffer.from(content); | ||
} | ||
|
||
return new Buffer(content); | ||
}; |