diff --git a/CHANGELOG.md b/CHANGELOG.md index 70a833a46b4b..5024d178279c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -74,6 +74,8 @@ - `[docs]` Update `setupFiles` documentation for clarity ([#7187](https://github.com/facebook/jest/pull/7187)) - `[docs]` Change `require.require*` to `jest.require*` ([#7210](https://github.com/facebook/jest/pull/7210)) - `[jest-circus]` Add readme.md ([#7198](https://github.com/facebook/jest/pull/7198)) +- `[jest-editor-support]` Remove from the repository ([#7232](https://github.com/facebook/jest/pull/7232)) +- `[jest-test-typescript-parser]` Remove from the repository ([#7232](https://github.com/facebook/jest/pull/7232)) ### Performance diff --git a/e2e/__tests__/to_match_inline_snapshot.test.js b/e2e/__tests__/to_match_inline_snapshot.test.js index 576edd7bcd34..c1a194dd9d69 100644 --- a/e2e/__tests__/to_match_inline_snapshot.test.js +++ b/e2e/__tests__/to_match_inline_snapshot.test.js @@ -47,9 +47,6 @@ test('basic support', () => { expect(fileAfter).toMatchSnapshot('snapshot passed'); } - // This test below also covers how jest-editor-support creates terse messages - // for letting a Snapshot update, so if the wording is updated, please edit - // /packages/jest-editor-support/src/test_reconciler.js { writeFiles(TESTS_DIR, { [filename]: readFile(filename).replace('original value', 'updated value'), diff --git a/e2e/__tests__/to_match_snapshot.test.js b/e2e/__tests__/to_match_snapshot.test.js index 001bb9e4c6f0..1d27428464a2 100644 --- a/e2e/__tests__/to_match_snapshot.test.js +++ b/e2e/__tests__/to_match_snapshot.test.js @@ -39,9 +39,6 @@ test('basic support', () => { expect(status).toBe(0); } - // This test below also covers how jest-editor-support creates terse messages - // for letting a Snapshot update, so if the wording is updated, please edit - // /packages/jest-editor-support/src/test_reconciler.js { writeFiles(TESTS_DIR, { [filename]: template(['{apple: "updated value"}']), diff --git a/packages/jest-editor-support/.npmignore b/packages/jest-editor-support/.npmignore deleted file mode 100644 index 85e48fe7b0a4..000000000000 --- a/packages/jest-editor-support/.npmignore +++ /dev/null @@ -1,3 +0,0 @@ -**/__mocks__/** -**/__tests__/** -src diff --git a/packages/jest-editor-support/README.md b/packages/jest-editor-support/README.md deleted file mode 100644 index 396d4ef310e7..000000000000 --- a/packages/jest-editor-support/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# jest-editor-support - -The engine that allows editors to build on top of Jest. - -## Usage - -This is only useful if you are interested in building an editor integration for Jest. - -For now as an end user, we'd recommend looking at either [vscode-jest](https://github.com/jest-community/vscode-jest/) or [majestic](https://github.com/Raathigesh/majestic/). - -## Note - -Since version `18.2.0` TypeScript is now a peer dependency. If you don't need to handle `.tsx` files then you can safely ignore the warning during installation. diff --git a/packages/jest-editor-support/index.d.ts b/packages/jest-editor-support/index.d.ts deleted file mode 100644 index a69949aedb72..000000000000 --- a/packages/jest-editor-support/index.d.ts +++ /dev/null @@ -1,196 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -import {EventEmitter} from 'events'; -import {ChildProcess} from 'child_process'; - -export interface SpawnOptions { - shell?: boolean; -} - -export interface Options { - createProcess?( - workspace: ProjectWorkspace, - args: string[], - options?: SpawnOptions, - ): ChildProcess; - noColor?: boolean; - testNamePattern?: string; - testFileNamePattern?: string; - shell?: boolean; -} - -export class Runner extends EventEmitter { - constructor(workspace: ProjectWorkspace, options?: Options); - watchMode: boolean; - watchAll: boolean; - start(watchMode?: boolean, watchAll?: boolean): void; - closeProcess(): void; - runJestWithUpdateForSnapshots(completion: any): void; -} - -export class Settings extends EventEmitter { - constructor(workspace: ProjectWorkspace, options?: Options); - getConfig(completed: Function): void; - jestVersionMajor: number | null; - settings: { - testRegex: string, - testMatch: string[], - }; -} - -export class ProjectWorkspace { - constructor( - rootPath: string, - pathToJest: string, - pathToConfig: string, - localJestMajorVersin: number, - collectCoverage?: boolean, - debug?: boolean, - ); - pathToJest: string; - pathToConfig: string; - rootPath: string; - localJestMajorVersion: number; - collectCoverage?: boolean; - debug?: boolean; -} - -export interface IParseResults { - expects: Expect[]; - itBlocks: ItBlock[]; -} - -export function parse(file: string): IParseResults; - -export interface Location { - column: number; - line: number; -} - -export class Node { - start: Location; - end: Location; - file: string; -} - -export class ItBlock extends Node { - name: string; -} - -export class Expect extends Node {} - -export class TestReconciler { - stateForTestFile(file: string): TestReconcilationState; - assertionsForTestFile(file: string): TestAssertionStatus[] | null; - stateForTestAssertion( - file: string, - name: string, - ): TestFileAssertionStatus | null; - updateFileWithJestStatus(data: any): TestFileAssertionStatus[]; -} - -/** - * Did the thing pass, fail or was it not run? - */ -export type TestReconcilationState = - | 'Unknown' // The file has not changed, so the watcher didn't hit it - | 'KnownFail' // Definitely failed - | 'KnownSuccess' // Definitely passed - | 'KnownSkip'; // Definitely skipped - -/** - * The Jest Extension's version of a status for - * whether the file passed or not - * - */ -export interface TestFileAssertionStatus { - file: string; - message: string; - status: TestReconcilationState; - assertions: Array | null; -} - -/** - * The Jest Extension's version of a status for - * individual assertion fails - * - */ -export interface TestAssertionStatus { - title: string; - status: TestReconcilationState; - message: string; - shortMessage?: string; - terseMessage?: string; - line?: number; -} - -export interface JestFileResults { - name: string; - summary: string; - message: string; - status: 'failed' | 'passed'; - startTime: number; - endTime: number; - assertionResults: Array; -} - -export interface JestAssertionResults { - name: string; - title: string; - status: 'failed' | 'passed'; - failureMessages: string[]; - fullName: string; -} - -export interface JestTotalResults { - success: boolean; - startTime: number; - numTotalTests: number; - numTotalTestSuites: number; - numRuntimeErrorTestSuites: number; - numPassedTests: number; - numFailedTests: number; - numPendingTests: number; - coverageMap: any; - testResults: Array; -} - -export interface JestTotalResultsMeta { - noTestsFound: boolean; -} - -export enum messageTypes { - noTests = 1, - testResults = 3, - unknown = 0, - watchUsage = 2, -} - -export type MessageType = number; - -export interface SnapshotMetadata { - exists: boolean; - name: string; - node: { - loc: Node; - }; - content?: string; -} - -export class Snapshot { - constructor(parser?: any, customMatchers?: string[]); - getMetadata(filepath: string): SnapshotMetadata[]; -} - -type FormattedTestResults = { - testResults: TestResult[] -} - -type TestResult = { - name: string -} \ No newline at end of file diff --git a/packages/jest-editor-support/package.json b/packages/jest-editor-support/package.json deleted file mode 100644 index 6b836825675b..000000000000 --- a/packages/jest-editor-support/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "jest-editor-support", - "version": "23.6.0", - "repository": { - "type": "git", - "url": "https://github.com/facebook/jest.git" - }, - "license": "MIT", - "main": "build/index.js", - "dependencies": { - "babel-traverse": "^6.14.1", - "babylon": "^6.14.1", - "jest-snapshot": "^23.6.0" - }, - "typings": "index.d.ts" -} diff --git a/packages/jest-editor-support/src/Process.js b/packages/jest-editor-support/src/Process.js deleted file mode 100644 index 52e3c7623a46..000000000000 --- a/packages/jest-editor-support/src/Process.js +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -import {ChildProcess, spawn} from 'child_process'; -import ProjectWorkspace from './project_workspace'; -import type {SpawnOptions} from './types'; - -/** - * Spawns and returns a Jest process with specific args - * - * @param {string[]} args - * @returns {ChildProcess} - */ -export const createProcess = ( - workspace: ProjectWorkspace, - args: Array, - options?: SpawnOptions = {}, -): ChildProcess => { - // A command could look like `npm run test`, which we cannot use as a command - // as they can only be the first command, so take out the command, and add - // any other bits into the args - const runtimeExecutable = workspace.pathToJest; - const parameters = runtimeExecutable.split(' '); - const command = parameters[0]; - const initialArgs = parameters.slice(1); - const runtimeArgs = [].concat(initialArgs, args); - - // If a path to configuration file was defined, push it to runtimeArgs - if (workspace.pathToConfig) { - runtimeArgs.push('--config'); - runtimeArgs.push(workspace.pathToConfig); - } - - // To use our own commands in create-react, we need to tell the command that - // we're in a CI environment, or it will always append --watch - const env = process.env; - env['CI'] = 'true'; - - const spawnOptions = { - cwd: workspace.rootPath, - env, - shell: options.shell, - }; - - if (workspace.debug) { - console.log( - `spawning process with command=${command}, args=${runtimeArgs.toString()}`, - ); - } - - return spawn(command, runtimeArgs, spawnOptions); -}; diff --git a/packages/jest-editor-support/src/Runner.js b/packages/jest-editor-support/src/Runner.js deleted file mode 100644 index 8282502713b5..000000000000 --- a/packages/jest-editor-support/src/Runner.js +++ /dev/null @@ -1,208 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -import type {Options, MessageType, SpawnOptions} from './types'; -import {messageTypes} from './types'; - -import {ChildProcess, spawn} from 'child_process'; -import {readFile} from 'fs'; -import {tmpdir} from 'os'; -import EventEmitter from 'events'; -import ProjectWorkspace from './project_workspace'; -import {createProcess} from './Process'; - -// This class represents the running process, and -// passes out events when it understands what data is being -// pass sent out of the process -export default class Runner extends EventEmitter { - debugprocess: ChildProcess; - outputPath: string; - workspace: ProjectWorkspace; - _createProcess: ( - workspace: ProjectWorkspace, - args: Array, - options?: SpawnOptions, - ) => ChildProcess; - watchMode: boolean; - watchAll: boolean; - options: Options; - prevMessageTypes: MessageType[]; - - constructor(workspace: ProjectWorkspace, options?: Options) { - super(); - - this._createProcess = (options && options.createProcess) || createProcess; - this.options = options || {}; - this.workspace = workspace; - this.outputPath = tmpdir() + '/jest_runner.json'; - this.prevMessageTypes = []; - } - - start(watchMode: boolean = true, watchAll: boolean = false) { - if (this.debugprocess) { - return; - } - - this.watchMode = watchMode; - this.watchAll = watchAll; - - // Handle the arg change on v18 - const belowEighteen = this.workspace.localJestMajorVersion < 18; - const outputArg = belowEighteen ? '--jsonOutputFile' : '--outputFile'; - - const args = ['--json', '--useStderr', outputArg, this.outputPath]; - if (this.watchMode) { - args.push(this.watchAll ? '--watchAll' : '--watch'); - } - if (this.options.testNamePattern) { - args.push('--testNamePattern', this.options.testNamePattern); - } - if (this.options.testFileNamePattern) { - args.push(this.options.testFileNamePattern); - } - if (this.workspace.collectCoverage === true) { - args.push('--coverage'); - } - if (this.workspace.collectCoverage === false) { - args.push('--no-coverage'); - } - if (this.options.noColor === true) { - args.push('--no-color'); - } - - const options = { - shell: this.options.shell, - }; - - this.debugprocess = this._createProcess(this.workspace, args, options); - this.debugprocess.stdout.on('data', (data: Buffer) => { - this._parseOutput(data, false); - }); - - this.debugprocess.stderr.on('data', (data: Buffer) => { - // jest 23 could send test results message to stderr - // see https://github.com/facebook/jest/pull/4858 - this._parseOutput(data, true); - }); - this.debugprocess.on('exit', () => { - this.emit('debuggerProcessExit'); - this.prevMessageTypes.length = 0; - }); - - this.debugprocess.on('error', (error: Error) => { - this.emit('terminalError', 'Process failed: ' + error.message); - this.prevMessageTypes.length = 0; - }); - - this.debugprocess.on('close', () => { - this.emit('debuggerProcessExit'); - this.prevMessageTypes.length = 0; - }); - } - - _parseOutput(data: Buffer, isStdErr: boolean): MessageType { - const msgType = this.findMessageType(data); - switch (msgType) { - case messageTypes.testResults: - readFile(this.outputPath, 'utf8', (err, data) => { - if (err) { - const message = `JSON report not found at ${this.outputPath}`; - this.emit('terminalError', message); - } else { - const noTestsFound = this.doResultsFollowNoTestsFoundMessage(); - this.emit('executableJSON', JSON.parse(data), { - noTestsFound, - }); - } - }); - this.prevMessageTypes.length = 0; - break; - case messageTypes.watchUsage: - case messageTypes.noTests: - this.prevMessageTypes.push(msgType); - this.emit('executableStdErr', data, { - type: msgType, - }); - break; - default: - // no special action needed, just report the output by its source - if (isStdErr) { - this.emit('executableStdErr', data, { - type: msgType, - }); - } else { - this.emit('executableOutput', data.toString().replace('', '')); - } - this.prevMessageTypes.length = 0; - break; - } - - return msgType; - } - - runJestWithUpdateForSnapshots(completion: any, args: string[]) { - const defaultArgs = ['--updateSnapshot']; - - const options = { - shell: this.options.shell, - }; - const updateProcess = this._createProcess( - this.workspace, - [...defaultArgs, ...(args ? args : [])], - options, - ); - updateProcess.on('close', () => { - completion(); - }); - } - - closeProcess() { - if (!this.debugprocess) { - return; - } - if (process.platform === 'win32') { - // Windows doesn't exit the process when it should. - spawn('taskkill', ['/pid', '' + this.debugprocess.pid, '/T', '/F']); - } else { - this.debugprocess.kill(); - } - delete this.debugprocess; - } - - findMessageType(buf: Buffer): MessageType { - const str = buf.toString('utf8', 0, 58); - const lastCommitRegex = /No tests found related to files changed since ((last commit)|("[a-z0-9]+"))./; - if (lastCommitRegex.test(str)) { - return messageTypes.noTests; - } - if (/^\s*Watch Usage\b/.test(str)) { - return messageTypes.watchUsage; - } - - if (str.trim().startsWith('Test results written to')) { - return messageTypes.testResults; - } - return messageTypes.unknown; - } - - doResultsFollowNoTestsFoundMessage() { - if (this.prevMessageTypes.length === 1) { - return this.prevMessageTypes[0] === messageTypes.noTests; - } - - if (this.prevMessageTypes.length === 2) { - return ( - this.prevMessageTypes[0] === messageTypes.noTests && - this.prevMessageTypes[1] === messageTypes.watchUsage - ); - } - - return false; - } -} diff --git a/packages/jest-editor-support/src/Settings.js b/packages/jest-editor-support/src/Settings.js deleted file mode 100644 index d11da69ab998..000000000000 --- a/packages/jest-editor-support/src/Settings.js +++ /dev/null @@ -1,120 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -import type {Options, SpawnOptions} from './types'; - -import {ChildProcess} from 'child_process'; -import EventEmitter from 'events'; -import ProjectWorkspace from './project_workspace'; -import {createProcess} from './Process'; - -// This class represents the the configuration of Jest's process -// we want to start with the defaults then override whatever they output -// the interface below can be used to show what we use, as currently the whole -// settings object will be in memory. - -// Ideally anything you care about adding should have a default in -// the constructor see https://jestjs.io/docs/configuration.html -// for full deets - -// For now, this is all we care about inside the config - -type Glob = string; - -type ConfigRepresentation = { - testRegex: string | Array, - testMatch: Array, -}; - -type ConfigRepresentations = Array; - -export default class Settings extends EventEmitter { - getConfigProcess: ChildProcess; - jestVersionMajor: number | null; - _createProcess: ( - workspace: ProjectWorkspace, - args: Array, - options: SpawnOptions, - ) => ChildProcess; - configs: ConfigRepresentations; - settings: ConfigRepresentation; - workspace: ProjectWorkspace; - spawnOptions: SpawnOptions; - _jsonPattern: RegExp; - - constructor(workspace: ProjectWorkspace, options?: Options) { - super(); - this.workspace = workspace; - this._createProcess = (options && options.createProcess) || createProcess; - this.spawnOptions = { - shell: options && options.shell, - }; - - // Defaults for a Jest project - this.settings = { - testMatch: ['**/__tests__/**/*.js?(x)', '**/?(*.)+(spec|test).js?(x)'], - testRegex: ['(/__tests__/.*|\\.(test|spec))\\.jsx?$'], - }; - - this.configs = [this.settings]; - this._jsonPattern = new RegExp(/^[\s]*\{/gm); - } - - _parseConfig(text: string): void { - let settings = null; - - try { - settings = JSON.parse(text); - } catch (err) { - // skip the non-json content, if any - const idx = text.search(this._jsonPattern); - if (idx > 0) { - if (this.workspace.debug) { - console.log(`skip config output noise: ${text.substring(0, idx)}`); - } - this._parseConfig(text.substring(idx)); - return; - } - console.warn(`failed to parse config: \n${text}\nerror: ${err}`); - throw err; - } - this.jestVersionMajor = parseInt(settings.version.split('.').shift(), 10); - this.configs = - this.jestVersionMajor >= 21 ? settings.configs : [settings.config]; - - if (this.workspace.debug) { - console.log(`found config jestVersionMajor=${this.jestVersionMajor}`); - } - } - - getConfigs(completed: any) { - this.getConfigProcess = this._createProcess( - this.workspace, - ['--showConfig'], - this.spawnOptions, - ); - - this.getConfigProcess.stdout.on('data', (data: Buffer) => { - this._parseConfig(data.toString()); - }); - - // They could have an older build of Jest which - // would error with `--showConfig` - this.getConfigProcess.on('close', () => { - completed(); - }); - } - - getConfig(completed: any, index: number = 0) { - this.getConfigs(() => { - this.settings = this.configs[index]; - completed(); - }); - } -} diff --git a/packages/jest-editor-support/src/Snapshot.js b/packages/jest-editor-support/src/Snapshot.js deleted file mode 100644 index 0b1334a6d2f2..000000000000 --- a/packages/jest-editor-support/src/Snapshot.js +++ /dev/null @@ -1,176 +0,0 @@ -/** - * 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'; - -import type {ProjectConfig} from 'types/Config'; - -import traverse from 'babel-traverse'; -import {getASTfor} from './parsers/babylon_parser'; -import {buildSnapshotResolver, utils} from 'jest-snapshot'; - -type Node = any; - -type SnapshotMetadata = { - exists: true | false, - name: string, - node: Node, - content?: string, -}; - -const describeVariants = Object.assign( - (Object.create(null): {[string]: boolean, __proto__: null}), - { - describe: true, - fdescribe: true, - xdescribe: true, - }, -); -const base = Object.assign( - (Object.create(null): {[string]: boolean, __proto__: null}), - { - describe: true, - it: true, - test: true, - }, -); -const decorators = Object.assign( - (Object.create(null): {[string]: boolean, __proto__: null}), - { - only: true, - skip: true, - }, -); - -const validParents = Object.assign( - (Object.create(null): any), - base, - describeVariants, - Object.assign((Object.create(null): {[string]: boolean, __proto__: null}), { - fit: true, - xit: true, - xtest: true, - }), -); - -const isValidMemberExpression = node => - node.object && - base[node.object.name] && - node.property && - decorators[node.property.name]; - -const isDescribe = node => - describeVariants[node.name] || - (isValidMemberExpression(node) && node.object.name === 'describe'); - -const isValidParent = parent => - parent.callee && - (validParents[parent.callee.name] || isValidMemberExpression(parent.callee)); - -const getArrayOfParents = path => { - const result = []; - let parent = path.parentPath; - while (parent) { - result.unshift(parent.node); - parent = parent.parentPath; - } - return result; -}; - -const buildName: ( - snapshotNode: Node, - parents: Array, - position: number, -) => string = (snapshotNode, parents, position) => { - const fullName = parents.map(parent => parent.arguments[0].value).join(' '); - - return utils.testNameToKey(fullName, position); -}; - -export default class Snapshot { - _parser: Function; - _matchers: Array; - _projectConfig: ?ProjectConfig; - constructor( - parser: any, - customMatchers?: Array, - projectConfig?: ProjectConfig, - ) { - this._parser = parser || getASTfor; - this._matchers = ['toMatchSnapshot', 'toThrowErrorMatchingSnapshot'].concat( - customMatchers || [], - ); - this._projectConfig = projectConfig; - } - - getMetadata(filePath: string): Array { - const fileNode = this._parser(filePath); - const state = { - found: [], - }; - const Visitors = { - Identifier(path, state, matchers) { - if (matchers.indexOf(path.node.name) >= 0) { - state.found.push({ - node: path.node, - parents: getArrayOfParents(path), - }); - } - }, - }; - - traverse(fileNode, { - enter: path => { - const visitor = Visitors[path.node.type]; - if (visitor != null) { - visitor(path, state, this._matchers); - } - }, - }); - - // NOTE if no projectConfig is given the default resolver will be used - const snapshotResolver = buildSnapshotResolver(this._projectConfig || {}); - const snapshotPath = snapshotResolver.resolveSnapshotPath(filePath); - const snapshots = utils.getSnapshotData(snapshotPath, 'none').data; - let lastParent = null; - let count = 1; - - return state.found.map((snapshotNode, index) => { - const parents = snapshotNode.parents.filter(isValidParent); - const innerAssertion = parents[parents.length - 1]; - - if (lastParent !== innerAssertion) { - lastParent = innerAssertion; - count = 1; - } - - const result = { - content: undefined, - count: count++, - exists: false, - name: '', - node: snapshotNode.node, - }; - - if (!innerAssertion || isDescribe(innerAssertion.callee)) { - // An expectation inside describe never gets executed. - return result; - } - - result.name = buildName(snapshotNode, parents, result.count); - - if (snapshots[result.name]) { - result.exists = true; - result.content = snapshots[result.name]; - } - return result; - }); - } -} diff --git a/packages/jest-editor-support/src/__tests__/fixtures/snapshots/__snapshots__/describe.example.snap b/packages/jest-editor-support/src/__tests__/fixtures/snapshots/__snapshots__/describe.example.snap deleted file mode 100644 index d60e6dc0998d..000000000000 --- a/packages/jest-editor-support/src/__tests__/fixtures/snapshots/__snapshots__/describe.example.snap +++ /dev/null @@ -1,91 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`DESCRIBE fit 1`] = `1 fit describe`; -exports[`DESCRIBE fit 2`] = `2 fit describe`; -exports[`DESCRIBE it 1`] = `1 it describe`; -exports[`DESCRIBE it 2`] = `2 it describe`; -exports[`DESCRIBE it.only 1`] = `1 it.only describe`; -exports[`DESCRIBE it.only 2`] = `2 it.only describe`; -exports[`DESCRIBE it.skip 1`] = `1 it.skip describe`; -exports[`DESCRIBE it.skip 2`] = `2 it.skip describe`; -exports[`DESCRIBE test 1`] = `1 test describe`; -exports[`DESCRIBE test 2`] = `2 test describe`; -exports[`DESCRIBE test.only 1`] = `1 test.only describe`; -exports[`DESCRIBE test.only 2`] = `2 test.only describe`; -exports[`DESCRIBE test.skip 1`] = `1 test.skip describe`; -exports[`DESCRIBE test.skip 2`] = `2 test.skip describe`; -exports[`DESCRIBE xit 1`] = `1 xit describe`; -exports[`DESCRIBE xit 2`] = `2 xit describe`; -exports[`DESCRIBE xtest 1`] = `1 xtest describe`; -exports[`DESCRIBE xtest 2`] = `2 xtest describe`; -exports[`DESCRIBE.ONLY fit 1`] = `1 fit describe.only`; -exports[`DESCRIBE.ONLY fit 2`] = `2 fit describe.only`; -exports[`DESCRIBE.ONLY it 1`] = `1 it describe.only`; -exports[`DESCRIBE.ONLY it 2`] = `2 it describe.only`; -exports[`DESCRIBE.ONLY it.only 1`] = `1 it.only describe.only`; -exports[`DESCRIBE.ONLY it.only 2`] = `2 it.only describe.only`; -exports[`DESCRIBE.ONLY it.skip 1`] = `1 it.skip describe.only`; -exports[`DESCRIBE.ONLY it.skip 2`] = `2 it.skip describe.only`; -exports[`DESCRIBE.ONLY test 1`] = `1 test describe.only`; -exports[`DESCRIBE.ONLY test 2`] = `2 test describe.only`; -exports[`DESCRIBE.ONLY test.only 1`] = `1 test.only describe.only`; -exports[`DESCRIBE.ONLY test.only 2`] = `2 test.only describe.only`; -exports[`DESCRIBE.ONLY test.skip 1`] = `1 test.skip describe.only`; -exports[`DESCRIBE.ONLY test.skip 2`] = `2 test.skip describe.only`; -exports[`DESCRIBE.ONLY xit 1`] = `1 xit describe.only`; -exports[`DESCRIBE.ONLY xit 2`] = `2 xit describe.only`; -exports[`DESCRIBE.ONLY xtest 1`] = `1 xtest describe.only`; -exports[`DESCRIBE.ONLY xtest 2`] = `2 xtest describe.only`; -exports[`DESCRIBE.SKIP fit 1`] = `1 fit describe.skip`; -exports[`DESCRIBE.SKIP fit 2`] = `2 fit describe.skip`; -exports[`DESCRIBE.SKIP it 1`] = `1 it describe.skip`; -exports[`DESCRIBE.SKIP it 2`] = `2 it describe.skip`; -exports[`DESCRIBE.SKIP it.only 1`] = `1 it.only describe.skip`; -exports[`DESCRIBE.SKIP it.only 2`] = `2 it.only describe.skip`; -exports[`DESCRIBE.SKIP it.skip 1`] = `1 it.skip describe.skip`; -exports[`DESCRIBE.SKIP it.skip 2`] = `2 it.skip describe.skip`; -exports[`DESCRIBE.SKIP test 1`] = `1 test describe.skip`; -exports[`DESCRIBE.SKIP test 2`] = `2 test describe.skip`; -exports[`DESCRIBE.SKIP test.only 1`] = `1 test.only describe.skip`; -exports[`DESCRIBE.SKIP test.only 2`] = `2 test.only describe.skip`; -exports[`DESCRIBE.SKIP test.skip 1`] = `1 test.skip describe.skip`; -exports[`DESCRIBE.SKIP test.skip 2`] = `2 test.skip describe.skip`; -exports[`DESCRIBE.SKIP xit 1`] = `1 xit describe.skip`; -exports[`DESCRIBE.SKIP xit 2`] = `2 xit describe.skip`; -exports[`DESCRIBE.SKIP xtest 1`] = `1 xtest describe.skip`; -exports[`DESCRIBE.SKIP xtest 2`] = `2 xtest describe.skip`; -exports[`FDESCRIBE fit 1`] = `1 fit fdescribe`; -exports[`FDESCRIBE fit 2`] = `2 fit fdescribe`; -exports[`FDESCRIBE it 1`] = `1 it fdescribe`; -exports[`FDESCRIBE it 2`] = `2 it fdescribe`; -exports[`FDESCRIBE it.only 1`] = `1 it.only fdescribe`; -exports[`FDESCRIBE it.only 2`] = `2 it.only fdescribe`; -exports[`FDESCRIBE it.skip 1`] = `1 it.skip fdescribe`; -exports[`FDESCRIBE it.skip 2`] = `2 it.skip fdescribe`; -exports[`FDESCRIBE test 1`] = `1 test fdescribe`; -exports[`FDESCRIBE test 2`] = `2 test fdescribe`; -exports[`FDESCRIBE test.only 1`] = `1 test.only fdescribe`; -exports[`FDESCRIBE test.only 2`] = `2 test.only fdescribe`; -exports[`FDESCRIBE test.skip 1`] = `1 test.skip fdescribe`; -exports[`FDESCRIBE test.skip 2`] = `2 test.skip fdescribe`; -exports[`FDESCRIBE xit 1`] = `1 xit fdescribe`; -exports[`FDESCRIBE xit 2`] = `2 xit fdescribe`; -exports[`FDESCRIBE xtest 1`] = `1 xtest fdescribe`; -exports[`FDESCRIBE xtest 2`] = `2 xtest fdescribe`; -exports[`XDESCRIBE fit 1`] = `1 fit xdescribe`; -exports[`XDESCRIBE fit 2`] = `2 fit xdescribe`; -exports[`XDESCRIBE it 1`] = `1 it xdescribe`; -exports[`XDESCRIBE it 2`] = `2 it xdescribe`; -exports[`XDESCRIBE it.only 1`] = `1 it.only xdescribe`; -exports[`XDESCRIBE it.only 2`] = `2 it.only xdescribe`; -exports[`XDESCRIBE it.skip 1`] = `1 it.skip xdescribe`; -exports[`XDESCRIBE it.skip 2`] = `2 it.skip xdescribe`; -exports[`XDESCRIBE test 1`] = `1 test xdescribe`; -exports[`XDESCRIBE test 2`] = `2 test xdescribe`; -exports[`XDESCRIBE test.only 1`] = `1 test.only xdescribe`; -exports[`XDESCRIBE test.only 2`] = `2 test.only xdescribe`; -exports[`XDESCRIBE test.skip 1`] = `1 test.skip xdescribe`; -exports[`XDESCRIBE test.skip 2`] = `2 test.skip xdescribe`; -exports[`XDESCRIBE xit 1`] = `1 xit xdescribe`; -exports[`XDESCRIBE xit 2`] = `2 xit xdescribe`; -exports[`XDESCRIBE xtest 1`] = `1 xtest xdescribe`; -exports[`XDESCRIBE xtest 2`] = `2 xtest xdescribe`; diff --git a/packages/jest-editor-support/src/__tests__/fixtures/snapshots/__snapshots__/nested.example.snap b/packages/jest-editor-support/src/__tests__/fixtures/snapshots/__snapshots__/nested.example.snap deleted file mode 100644 index ee8a6ffce3a2..000000000000 --- a/packages/jest-editor-support/src/__tests__/fixtures/snapshots/__snapshots__/nested.example.snap +++ /dev/null @@ -1,3 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`outer describe outer it inner describe inner it 1`] = `first nested`; -exports[`outer describe outer it inner describe inner it 2`] = `second nested`; diff --git a/packages/jest-editor-support/src/__tests__/fixtures/snapshots/__snapshots__/nodescribe.example.snap b/packages/jest-editor-support/src/__tests__/fixtures/snapshots/__snapshots__/nodescribe.example.snap deleted file mode 100644 index 8b6c8955d07b..000000000000 --- a/packages/jest-editor-support/src/__tests__/fixtures/snapshots/__snapshots__/nodescribe.example.snap +++ /dev/null @@ -1,19 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`fit 1`]=`fit 1`; -exports[`fit 2`]=`fit 2`; -exports[`it 1`]=`it 1`; -exports[`it 2`]=`it 2`; -exports[`it.only 1`]=`it.only 1`; -exports[`it.only 2`]=`it.only 2`; -exports[`it.skip 1`]=`it.skip 1`; -exports[`it.skip 2`]=`it.skip 2`; -exports[`test 1`]=`test 1`; -exports[`test 2`]=`test 2`; -exports[`test.only 1`]=`test.only 1`; -exports[`test.only 2`]=`test.only 2`; -exports[`test.skip 1`]=`test.skip 1`; -exports[`test.skip 2`]=`test.skip 2`; -exports[`xit 1`]=`xit 1`; -exports[`xit 2`]=`xit 2`; -exports[`xtest 1`]=`xtest 1`; -exports[`xtest 2`]=`xtest 2`; diff --git a/packages/jest-editor-support/src/__tests__/fixtures/snapshots/describe.example b/packages/jest-editor-support/src/__tests__/fixtures/snapshots/describe.example deleted file mode 100644 index 5380757ef2e8..000000000000 --- a/packages/jest-editor-support/src/__tests__/fixtures/snapshots/describe.example +++ /dev/null @@ -1,194 +0,0 @@ -describe('DESCRIBE', () => { - fit('fit', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - it('it', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - it.only('it.only', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - it.skip('it.skip', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - test('test', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - test.only('test.only', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - test.skip('test.skip', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - xit('xit', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - xtest('xtest', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) -}) - -describe.only('DESCRIBE.ONLY', () => { - fit('fit', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - it('it', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - it.only('it.only', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - it.skip('it.skip', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - test('test', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - test.only('test.only', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - test.skip('test.skip', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - xit('xit', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - xtest('xtest', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) -}) - -describe.skip('DESCRIBE.SKIP', () => { - fit('fit', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - it('it', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - it.only('it.only', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - it.skip('it.skip', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - test('test', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - test.only('test.only', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - test.skip('test.skip', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - xit('xit', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - xtest('xtest', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) -}) - -fdescribe('FDESCRIBE', () => { - fit('fit', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - it('it', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - it.only('it.only', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - it.skip('it.skip', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - test('test', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - test.only('test.only', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - test.skip('test.skip', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - xit('xit', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - xtest('xtest', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) -}) - -xdescribe('XDESCRIBE', () => { - fit('fit', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - it('it', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - it.only('it.only', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - it.skip('it.skip', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - test('test', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - test.only('test.only', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - test.skip('test.skip', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - xit('xit', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - xtest('xtest', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) -}) diff --git a/packages/jest-editor-support/src/__tests__/fixtures/snapshots/nested.example b/packages/jest-editor-support/src/__tests__/fixtures/snapshots/nested.example deleted file mode 100644 index 260bd5a556a4..000000000000 --- a/packages/jest-editor-support/src/__tests__/fixtures/snapshots/nested.example +++ /dev/null @@ -1,10 +0,0 @@ -describe('outer describe', () => { - it('outer it', () => { - describe('inner describe', () => { - it('inner it', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); - }) - }) - }) -}) diff --git a/packages/jest-editor-support/src/__tests__/fixtures/snapshots/nodescribe.example b/packages/jest-editor-support/src/__tests__/fixtures/snapshots/nodescribe.example deleted file mode 100644 index 90634fdc7560..000000000000 --- a/packages/jest-editor-support/src/__tests__/fixtures/snapshots/nodescribe.example +++ /dev/null @@ -1,36 +0,0 @@ -fit('fit', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); -}) -it('it', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); -}) -it.only('it.only', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); -}) -it.skip('it.skip', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); -}) -test('test', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); -}) -test.only('test.only', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); -}) -test.skip('test.skip', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); -}) -xit('xit', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); -}) -xtest('xtest', () => { - expect(fake).toMatchSnapshot(); - expect(fake).toMatchSnapshot(); -}) diff --git a/packages/jest-editor-support/src/__tests__/parsers/babylon_parser.test.js b/packages/jest-editor-support/src/__tests__/parsers/babylon_parser.test.js deleted file mode 100644 index 833d35dce23d..000000000000 --- a/packages/jest-editor-support/src/__tests__/parsers/babylon_parser.test.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -'use strict'; - -const {parse} = require('../../parsers/babylon_parser'); -const {parserTests} = require('../../../../../fixtures/parser_tests'); - -parserTests(parse); diff --git a/packages/jest-editor-support/src/__tests__/process.test.js b/packages/jest-editor-support/src/__tests__/process.test.js deleted file mode 100644 index 7b4bc0e844b5..000000000000 --- a/packages/jest-editor-support/src/__tests__/process.test.js +++ /dev/null @@ -1,126 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -'use strict'; - -jest.mock('child_process'); - -import {createProcess} from '../Process'; -import {spawn} from 'child_process'; - -describe('createProcess', () => { - afterEach(() => { - jest.resetAllMocks(); - }); - - it('spawns the process', () => { - const workspace: any = {pathToJest: ''}; - const args = []; - createProcess(workspace, args); - - expect(spawn).toBeCalled(); - }); - - it('spawns the command from workspace.pathToJest', () => { - const workspace: any = {pathToJest: 'jest'}; - const args = []; - createProcess(workspace, args); - - expect(spawn.mock.calls[0][0]).toBe('jest'); - expect(spawn.mock.calls[0][1]).toEqual([]); - }); - - it('spawns the first arg from workspace.pathToJest split on " "', () => { - const workspace: any = {pathToJest: 'npm test --'}; - const args = []; - createProcess(workspace, args); - - expect(spawn.mock.calls[0][0]).toBe('npm'); - expect(spawn.mock.calls[0][1]).toEqual(['test', '--']); - }); - - it('fails to spawn the first quoted arg from workspace.pathToJest', () => { - const workspace: any = { - pathToJest: - '"../build scripts/test" --coverageDirectory="../code coverage"', - }; - const args = []; - createProcess(workspace, args); - - expect(spawn.mock.calls[0][0]).not.toBe('"../build scripts/test"'); - expect(spawn.mock.calls[0][1]).not.toEqual([ - '--coverageDirectory="../code coverage"', - ]); - }); - - it('appends args', () => { - const workspace: any = {pathToJest: 'npm test --'}; - const args = ['--option', 'value', '--another']; - createProcess(workspace, args); - - expect(spawn.mock.calls[0][1]).toEqual(['test', '--', ...args]); - }); - - it('sets the --config arg to workspace.pathToConfig', () => { - const workspace: any = { - pathToConfig: 'non-standard.jest.js', - pathToJest: 'npm test --', - }; - const args = ['--option', 'value']; - createProcess(workspace, args); - - expect(spawn.mock.calls[0][1]).toEqual([ - 'test', - '--', - '--option', - 'value', - '--config', - 'non-standard.jest.js', - ]); - }); - - it('defines the "CI" environment variable', () => { - const expected = Object.assign({}, process.env, {CI: 'true'}); - - const workspace: any = {pathToJest: ''}; - const args = []; - createProcess(workspace, args); - - expect(spawn.mock.calls[0][2].env).toEqual(expected); - }); - - it('sets the current working directory of the child process', () => { - const workspace: any = { - pathToJest: '', - rootPath: 'root directory', - }; - const args = []; - createProcess(workspace, args); - - expect(spawn.mock.calls[0][2].cwd).toBe(workspace.rootPath); - }); - - it('should not set the "shell" property when "options" are not provided', () => { - const workspace: any = {pathToJest: ''}; - const args = []; - createProcess(workspace, args); - - expect(spawn.mock.calls[0][2].shell).not.toBeDefined(); - }); - - it('should set the "shell" property when "options" are provided', () => { - const expected = {}; - const workspace: any = {pathToJest: ''}; - const args = []; - const options: any = {shell: expected}; - createProcess(workspace, args, options); - - expect(spawn.mock.calls[0][2].shell).toBe(expected); - }); -}); diff --git a/packages/jest-editor-support/src/__tests__/project_workspace.test.js b/packages/jest-editor-support/src/__tests__/project_workspace.test.js deleted file mode 100644 index 3f5cb3b770ef..000000000000 --- a/packages/jest-editor-support/src/__tests__/project_workspace.test.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -'use strict'; - -import ProjectWorkspace from '../project_workspace'; - -describe('setup', () => { - it('sets itself up fom the constructor', () => { - const workspace = new ProjectWorkspace( - 'root_path', - 'path_to_jest', - 'path_to_config', - 1000, - ); - expect(workspace.rootPath).toEqual('root_path'); - expect(workspace.pathToJest).toEqual('path_to_jest'); - }); -}); diff --git a/packages/jest-editor-support/src/__tests__/runner.test.js b/packages/jest-editor-support/src/__tests__/runner.test.js deleted file mode 100644 index ad1999727583..000000000000 --- a/packages/jest-editor-support/src/__tests__/runner.test.js +++ /dev/null @@ -1,530 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -'use strict'; - -jest.mock('../Process'); -jest.mock('child_process', () => ({spawn: jest.fn()})); -jest.mock('os', () => ({tmpdir: jest.fn()})); -jest.mock('fs', () => { - // $FlowFixMe requireActual - const readFileSync = jest.requireActual('fs').readFileSync; - - // Replace `readFile` with `readFileSync` so we don't get multiple threads - return { - readFile: (path, type, closure) => { - const data = readFileSync(path); - closure(null, data); - }, - readFileSync, - }; -}); - -const path = require('path'); -const fixtures = path.resolve(__dirname, '../../../../fixtures'); -import ProjectWorkspace from '../project_workspace'; -import {messageTypes} from '../types'; - -import {default as Runner} from '../Runner'; -import {createProcess} from '../Process'; -import {tmpdir} from 'os'; -import {spawn} from 'child_process'; -import {readFileSync} from 'fs'; -import EventEmitter from 'events'; -import type {ChildProcess} from 'child_process'; - -describe('Runner', () => { - describe('constructor', () => { - it('does not set watchMode', () => { - const workspace: any = {}; - const sut = new Runner(workspace); - - expect(sut.watchMode).not.toBeDefined(); - }); - - it('does not set watchAll', () => { - const workspace: any = {}; - const sut = new Runner(workspace); - - expect(sut.watchAll).not.toBeDefined(); - }); - - it('sets the output filepath', () => { - tmpdir.mockReturnValueOnce('tmpdir'); - - const workspace: any = {}; - const sut = new Runner(workspace); - - expect(sut.outputPath).toBe('tmpdir/jest_runner.json'); - }); - - it('sets the default options', () => { - const workspace: any = {}; - const sut = new Runner(workspace); - - expect(sut.options).toEqual({}); - }); - - it('sets the options', () => { - const workspace: any = {}; - const options = {}; - const sut = new Runner(workspace, options); - - expect(sut.options).toBe(options); - }); - }); - - describe('start', () => { - beforeEach(() => { - jest.resetAllMocks(); - - (createProcess: any).mockImplementationOnce( - (workspace, args, options) => { - const process: any = new EventEmitter(); - process.stdout = new EventEmitter(); - process.stderr = new EventEmitter(); - return process; - }, - ); - }); - - it('will not start when started', () => { - const workspace: any = {}; - const sut = new Runner(workspace); - - sut.start(); - sut.start(); - - expect(createProcess).toHaveBeenCalledTimes(1); - }); - - it('sets watchMode', () => { - const expected = true; - - const workspace: any = {}; - const sut = new Runner(workspace); - sut.start(expected); - - expect(sut.watchMode).toBe(expected); - }); - - it('sets watchAll', () => { - const watchMode = true; - const watchAll = true; - - const workspace: any = {}; - const sut = new Runner(workspace); - sut.start(watchMode, watchAll); - - expect(sut.watchMode).toBe(watchMode); - expect(sut.watchAll).toBe(watchAll); - }); - - it('calls createProcess', () => { - const workspace: any = {}; - const sut = new Runner(workspace); - sut.start(false); - - expect((createProcess: any).mock.calls[0][0]).toBe(workspace); - }); - - it('calls createProcess with the --json arg', () => { - const workspace: any = {}; - const sut = new Runner(workspace); - sut.start(false); - - expect((createProcess: any).mock.calls[0][1]).toContain('--json'); - }); - - it('calls createProcess with the --useStderr arg', () => { - const workspace: any = {}; - const sut = new Runner(workspace); - sut.start(false); - - expect((createProcess: any).mock.calls[0][1]).toContain('--useStderr'); - }); - - it('calls createProcess with the --jsonOutputFile arg for Jest 17 and below', () => { - const workspace: any = {localJestMajorVersion: 17}; - const sut = new Runner(workspace); - sut.start(false); - - const args = (createProcess: any).mock.calls[0][1]; - const index = args.indexOf('--jsonOutputFile'); - expect(index).not.toBe(-1); - expect(args[index + 1]).toBe(sut.outputPath); - }); - - it('calls createProcess with the --outputFile arg for Jest 18 and above', () => { - const workspace: any = {localJestMajorVersion: 18}; - const sut = new Runner(workspace); - sut.start(false); - - const args = (createProcess: any).mock.calls[0][1]; - const index = args.indexOf('--outputFile'); - expect(index).not.toBe(-1); - expect(args[index + 1]).toBe(sut.outputPath); - }); - - it('calls createProcess with the --watch arg when provided', () => { - const workspace: any = {}; - const sut = new Runner(workspace); - sut.start(true); - - expect((createProcess: any).mock.calls[0][1]).toContain('--watch'); - }); - - it('calls createProcess with the --coverage arg when provided', () => { - const expected = '--coverage'; - - const workspace: any = {collectCoverage: true}; - const options = {}; - const sut = new Runner(workspace, options); - sut.start(false); - - const args = (createProcess: any).mock.calls[0][1]; - const index = args.indexOf(expected); - expect(index).not.toBe(-1); - }); - - it('calls createProcess with the ---no-coverage arg when provided and false', () => { - const expected = '--no-coverage'; - - const workspace: any = {collectCoverage: false}; - const options = {}; - const sut = new Runner(workspace, options); - sut.start(false); - - const args = (createProcess: any).mock.calls[0][1]; - const index = args.indexOf(expected); - expect(index).not.toBe(-1); - }); - - it('calls createProcess without the --coverage arg when undefined', () => { - const expected = '--coverage'; - - const workspace: any = {}; - const options = {}; - const sut = new Runner(workspace, options); - sut.start(false); - - const args = (createProcess: any).mock.calls[0][1]; - const index = args.indexOf(expected); - expect(index).toBe(-1); - }); - - it('calls createProcess with the --testNamePattern arg when provided', () => { - const expected = 'testNamePattern'; - - const workspace: any = {}; - const options = {testNamePattern: expected}; - const sut = new Runner(workspace, options); - sut.start(false); - - const args = (createProcess: any).mock.calls[0][1]; - const index = args.indexOf('--testNamePattern'); - expect(index).not.toBe(-1); - expect(args[index + 1]).toBe(expected); - }); - - it('calls createProcess with a test path pattern when provided', () => { - const expected = 'testPathPattern'; - const workspace: any = {}; - const options = {testFileNamePattern: expected}; - const sut = new Runner(workspace, options); - sut.start(false); - - expect((createProcess: any).mock.calls[0][1]).toContain(expected); - }); - - it('calls createProcess with the shell option when provided', () => { - const workspace: any = {}; - const options = {shell: true}; - const sut = new Runner(workspace, options); - sut.start(false); - - expect((createProcess: any).mock.calls[0][2]).toEqual({shell: true}); - }); - - it('calls createProcess with the no color option when provided', () => { - const expected = '--no-color'; - - const workspace: any = {}; - const options = {noColor: true}; - const sut = new Runner(workspace, options); - sut.start(false); - - expect((createProcess: any).mock.calls[0][1]).toContain(expected); - }); - }); - - describe('closeProcess', () => { - let platformPV; - - beforeEach(() => { - jest.resetAllMocks(); - platformPV = process.platform; - - // Remove the "process.platform" property descriptor so it can be writable. - delete process.platform; - }); - - afterEach(() => { - process.platform = platformPV; - }); - - it('does nothing if the runner has not started', () => { - const workspace: any = {}; - const sut = new Runner(workspace); - sut.closeProcess(); - - expect(spawn).not.toBeCalled(); - }); - - it('spawns taskkill to close the process on Windows', () => { - const workspace: any = {}; - const sut = new Runner(workspace); - process.platform = 'win32'; - sut.debugprocess = ({pid: 123}: any); - sut.closeProcess(); - - expect(spawn).toBeCalledWith('taskkill', ['/pid', '123', '/T', '/F']); - }); - - it('calls kill() to close the process on POSIX', () => { - const workspace: any = {}; - const sut = new Runner(workspace); - process.platform = 'posix'; - const kill = jest.fn(); - sut.debugprocess = ({kill}: any); - sut.closeProcess(); - - expect(kill).toBeCalledWith(); - }); - - it('clears the debugprocess property', () => { - const workspace: any = {}; - const sut = new Runner(workspace); - sut.debugprocess = ({kill: () => {}}: any); - sut.closeProcess(); - - expect(sut.debugprocess).not.toBeDefined(); - }); - }); -}); - -describe('events', () => { - let runner: Runner; - let fakeProcess: ChildProcess; - - beforeEach(() => { - jest.resetAllMocks(); - - fakeProcess = (new EventEmitter(): any); - fakeProcess.stdout = new EventEmitter(); - fakeProcess.stderr = new EventEmitter(); - fakeProcess.kill = () => {}; - - (createProcess: any).mockImplementation(() => fakeProcess); - - const workspace = new ProjectWorkspace( - '.', - 'node_modules/.bin/jest', - 'test', - 18, - ); - runner = new Runner(workspace); - - // Sets it up and registers for notifications - runner.start(); - }); - - it('expects JSON from both stdout and stderr, then it passes the JSON', () => { - const data = jest.fn(); - runner.on('executableJSON', data); - - runner.outputPath = `${fixtures}/failing-jsons/failing_jest_json.json`; - - const doTest = (out: stream$Readable) => { - data.mockClear(); - - // Emitting data through stdout should trigger sending JSON - out.emit('data', 'Test results written to file'); - expect(data).toBeCalled(); - - // And lets check what we emit - const dataAtPath = readFileSync(runner.outputPath); - const storedJSON = JSON.parse(dataAtPath.toString()); - expect(data.mock.calls[0][0]).toEqual(storedJSON); - }; - - doTest(fakeProcess.stdout); - doTest(fakeProcess.stderr); - }); - - it('emits errors when process errors', () => { - const error = jest.fn(); - runner.on('terminalError', error); - fakeProcess.emit('error', {}); - expect(error).toBeCalled(); - }); - - it('emits debuggerProcessExit when process exits', () => { - const close = jest.fn(); - runner.on('debuggerProcessExit', close); - fakeProcess.emit('exit'); - expect(close).toBeCalled(); - }); - - it('should start jest process after killing the old process', () => { - runner.closeProcess(); - runner.start(); - - expect(createProcess).toHaveBeenCalledTimes(2); - }); - - describe('stdout.on("data")', () => { - it('should emit an "executableJSON" event with the "noTestsFound" meta data property set', () => { - const listener = jest.fn(); - runner.on('executableJSON', listener); - runner.outputPath = `${fixtures}/failing-jsons/failing_jest_json.json`; - (runner: any).doResultsFollowNoTestsFoundMessage = jest - .fn() - .mockReturnValueOnce(true); - fakeProcess.stdout.emit('data', 'Test results written to file'); - - expect(listener.mock.calls[0].length).toBe(2); - expect(listener.mock.calls[0][1]).toEqual({noTestsFound: true}); - }); - - it('should clear the message type history', () => { - runner.outputPath = `${fixtures}/failing-jsons/failing_jest_json.json`; - runner.prevMessageTypes.push(messageTypes.noTests); - fakeProcess.stdout.emit('data', 'Test results written to file'); - - expect(runner.prevMessageTypes.length).toBe(0); - }); - }); - - describe('stderr.on("data")', () => { - it('should identify the message type', () => { - (runner: any).findMessageType = jest.fn(); - const expected = {}; - fakeProcess.stderr.emit('data', expected); - - expect(runner.findMessageType).toBeCalledWith(expected); - }); - - it('should add the type to the message type history when known', () => { - (runner: any).findMessageType = jest - .fn() - .mockReturnValueOnce(messageTypes.noTests); - fakeProcess.stderr.emit('data', Buffer.from('')); - - expect(runner.prevMessageTypes).toEqual([messageTypes.noTests]); - }); - - it('should clear the message type history when the type is unknown', () => { - (runner: any).findMessageType = jest - .fn() - .mockReturnValueOnce(messageTypes.unknown); - fakeProcess.stderr.emit('data', Buffer.from('')); - - expect(runner.prevMessageTypes).toEqual([]); - }); - - it('should emit an "executableStdErr" event with the type', () => { - const listener = jest.fn(); - const data = Buffer.from(''); - const type = {}; - const meta = {type}; - (runner: any).findMessageType = jest.fn().mockReturnValueOnce(type); - - runner.on('executableStdErr', listener); - fakeProcess.stderr.emit('data', data, meta); - - expect(listener).toBeCalledWith(data, meta); - }); - - it('should track when "No tests found related to files changed since the last commit" is received', () => { - const data = Buffer.from( - 'No tests found related to files changed since last commit.\n' + - 'Press `a` to run all tests, or run Jest with `--watchAll`.', - ); - fakeProcess.stderr.emit('data', data); - - expect(runner.prevMessageTypes).toEqual([messageTypes.noTests]); - }); - - it('should track when "No tests found related to files changed since master" is received', () => { - const data = Buffer.from( - 'No tests found related to files changed since "master".\n' + - 'Press `a` to run all tests, or run Jest with `--watchAll`.', - ); - fakeProcess.stderr.emit('data', data); - - expect(runner.prevMessageTypes).toEqual([messageTypes.noTests]); - }); - - it('should clear the message type history when any other other data is received', () => { - const data = Buffer.from(''); - fakeProcess.stderr.emit('data', data); - - expect(runner.prevMessageTypes).toEqual([]); - }); - }); - - describe('findMessageType()', () => { - it('should return "unknown" when the message is not matched', () => { - const buf = Buffer.from(''); - expect(runner.findMessageType(buf)).toBe(messageTypes.unknown); - }); - - it('should identify "No tests found related to files changed since last commit."', () => { - const buf = Buffer.from( - 'No tests found related to files changed since last commit.\n' + - 'Press `a` to run all tests, or run Jest with `--watchAll`.', - ); - expect(runner.findMessageType(buf)).toBe(messageTypes.noTests); - }); - - it('should identify "No tests found related to files changed since git ref."', () => { - const buf = Buffer.from( - 'No tests found related to files changed since "master".\n' + - 'Press `a` to run all tests, or run Jest with `--watchAll`.', - ); - expect(runner.findMessageType(buf)).toBe(messageTypes.noTests); - }); - - it('should identify the "Watch Usage" prompt', () => { - const buf = Buffer.from('\n\nWatch Usage\n...'); - expect(runner.findMessageType(buf)).toBe(messageTypes.watchUsage); - }); - }); - - describe('doResultsFollowNoTestsFoundMessage()', () => { - it('should return true when the last message on stderr was "No tests found..."', () => { - runner.prevMessageTypes.push(messageTypes.noTests); - expect(runner.doResultsFollowNoTestsFoundMessage()).toBe(true); - }); - - it('should return true when the last two messages on stderr were "No tests found..." and "Watch Usage"', () => { - runner.prevMessageTypes.push( - messageTypes.noTests, - messageTypes.watchUsage, - ); - expect(runner.doResultsFollowNoTestsFoundMessage()).toBe(true); - }); - - it('should return false otherwise', () => { - runner.prevMessageTypes.length = 0; - expect(runner.doResultsFollowNoTestsFoundMessage()).toBe(false); - }); - }); -}); diff --git a/packages/jest-editor-support/src/__tests__/settings.test.js b/packages/jest-editor-support/src/__tests__/settings.test.js deleted file mode 100644 index 9bcbae225f0a..000000000000 --- a/packages/jest-editor-support/src/__tests__/settings.test.js +++ /dev/null @@ -1,271 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -'use strict'; - -import EventEmitter from 'events'; -import ProjectWorkspace from '../project_workspace'; -import Settings from '../Settings'; - -describe('Settings', () => { - it('sets itself up fom the constructor', () => { - const workspace = new ProjectWorkspace( - 'root_path', - 'path_to_jest', - 'test', - 1000, - ); - const options = { - shell: true, - }; - const settings = new Settings(workspace, options); - expect(settings.workspace).toEqual(workspace); - expect(settings.settings).toEqual(expect.any(Object)); - expect(settings.spawnOptions).toEqual(options); - }); - - it('[jest 20] reads and parses the config', () => { - const workspace = new ProjectWorkspace( - 'root_path', - 'path_to_jest', - 'test', - 1000, - ); - const completed = jest.fn(); - const config = { - cacheDirectory: '/tmp/jest', - name: '[md5 hash]', - }; - const json = { - config, - version: '19.0.0', - }; - - const mockProcess: any = new EventEmitter(); - mockProcess.stdout = new EventEmitter(); - const createProcess = () => mockProcess; - const buffer = makeBuffer(JSON.stringify(json)); - const settings = new Settings(workspace, { - createProcess, - }); - - settings.getConfig(completed); - settings.getConfigProcess.stdout.emit('data', buffer); - settings.getConfigProcess.emit('close'); - - expect(completed).toHaveBeenCalled(); - expect(settings.jestVersionMajor).toBe(19); - expect(settings.settings).toEqual(config); - }); - - it('[jest 21] reads and parses the config', () => { - const workspace = new ProjectWorkspace( - 'root_path', - 'path_to_jest', - 'test', - 1000, - ); - const completed = jest.fn(); - const configs = [ - { - cacheDirectory: '/tmp/jest', - name: '[md5 hash]', - }, - ]; - const json = { - configs, - version: '21.0.0', - }; - - const mockProcess: any = new EventEmitter(); - mockProcess.stdout = new EventEmitter(); - const createProcess = () => mockProcess; - const buffer = makeBuffer(JSON.stringify(json)); - const settings = new Settings(workspace, { - createProcess, - }); - - settings.getConfig(completed); - settings.getConfigProcess.stdout.emit('data', buffer); - settings.getConfigProcess.emit('close'); - - expect(completed).toHaveBeenCalled(); - expect(settings.jestVersionMajor).toBe(21); - expect(settings.settings).toEqual(configs[0]); - }); - - it('[jest 21] reads and parses the configs', () => { - const workspace = new ProjectWorkspace( - 'root_path', - 'path_to_jest', - 'test', - 1000, - ); - const completed = jest.fn(); - const configs = [ - { - cacheDirectory: '/tmp/jest', - name: '[md5 hash]', - }, - ]; - const json = { - configs, - version: '21.0.0', - }; - - const mockProcess: any = new EventEmitter(); - mockProcess.stdout = new EventEmitter(); - const createProcess = () => mockProcess; - const buffer = makeBuffer(JSON.stringify(json)); - const settings = new Settings(workspace, { - createProcess, - }); - - settings.getConfigs(completed); - settings.getConfigProcess.stdout.emit('data', buffer); - settings.getConfigProcess.emit('close'); - - expect(completed).toHaveBeenCalled(); - expect(settings.jestVersionMajor).toBe(21); - expect(settings.configs).toEqual(configs); - }); - - it('calls callback even if no data is sent', () => { - const workspace = new ProjectWorkspace( - 'root_path', - 'path_to_jest', - 'test', - 1000, - ); - const completed = jest.fn(); - - const mockProcess: any = new EventEmitter(); - mockProcess.stdout = new EventEmitter(); - const createProcess = () => mockProcess; - const settings = new Settings(workspace, { - createProcess, - }); - - settings.getConfig(completed); - settings.getConfigProcess.emit('close'); - - expect(completed).toHaveBeenCalled(); - }); - - it('passes command, args, and options to createProcess', () => { - const localJestMajorVersion = 1000; - const pathToConfig = 'test'; - const pathToJest = 'path_to_jest'; - const rootPath = 'root_path'; - - const workspace = new ProjectWorkspace( - rootPath, - pathToJest, - pathToConfig, - localJestMajorVersion, - ); - const createProcess = jest.fn().mockReturnValue({ - on: () => {}, - stdout: new EventEmitter(), - }); - - const options: any = { - createProcess, - shell: true, - }; - const settings = new Settings(workspace, options); - settings.getConfig(() => {}); - - expect(createProcess).toBeCalledWith( - { - localJestMajorVersion, - pathToConfig, - pathToJest, - rootPath, - }, - ['--showConfig'], - { - shell: true, - }, - ); - }); - - describe('parse config', () => { - const workspace = new ProjectWorkspace( - 'root_path', - 'path_to_jest', - 'test', - 1000, - ); - const createProcess = jest.fn(); - - const json = `{ - "version": "23.2.0", - "configs": [{ - "testRegex": "some-regex" - }] - }`; - const run_test = ( - text: string, - expected_version: number = 23, - expected_regex: string = 'some-regex', - ): void => { - settings._parseConfig(text); - const target = settings.configs[0]; - expect(settings.jestVersionMajor).toBe(expected_version); - expect(target.testRegex).toBe(expected_regex); - }; - - let settings; - beforeEach(() => { - settings = new Settings(workspace, { - createProcess, - }); - }); - - it('test regex', () => { - const regex = settings._jsonPattern; - - let text = ` > abc {} - { abc } - `; - let index = text.search(regex); - expect(index).not.toBe(-1); - expect(text.substring(index).trim()).toBe('{ abc }'); - - text = `{def: - {sub} - }`; - index = text.search(regex); - expect(index).not.toBe(-1); - expect(text.substring(index).startsWith('{def:')).toBe(true); - }); - it('can parse correct config', () => { - run_test(json); - }); - - it('can parse config even with noise', () => { - const with_noise = ` - > something - > more noise - ${json} - `; - run_test(with_noise); - }); - }); -}); - -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); -}; diff --git a/packages/jest-editor-support/src/__tests__/snapshot.test.js b/packages/jest-editor-support/src/__tests__/snapshot.test.js deleted file mode 100644 index b93837484592..000000000000 --- a/packages/jest-editor-support/src/__tests__/snapshot.test.js +++ /dev/null @@ -1,131 +0,0 @@ -/** - * 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'; - -import path from 'path'; -import Snapshot from '../Snapshot'; - -const snapshotHelper = new Snapshot(); -const snapshotFixturePath = path.resolve(__dirname, 'fixtures/snapshots'); - -test('nodescribe.example', () => { - const filePath = path.join(snapshotFixturePath, 'nodescribe.example'); - const results = snapshotHelper.getMetadata(filePath); - const allAssertion = [ - 'fit', - 'it', - 'it.only', - 'it.skip', - 'test', - 'test.only', - 'test.skip', - 'xit', - 'xtest', - ]; - - const expectations = Object.create(null); - allAssertion.forEach(assertion => { - expectations[assertion + ' 1'] = { - assertion, - checked: false, - number: 1, - }; - expectations[assertion + ' 2'] = { - assertion, - checked: false, - number: 2, - }; - }); - - results.forEach(result => { - const check = expectations[result.name]; - check.checked = result.content === `${check.assertion} ${check.number}`; - }); - - expect( - Object.keys(expectations) - .map(key => expectations[key]) - .filter(expectation => !expectation.checked).length, - ).toBe(0); -}); - -test('describe.example', () => { - const filePath = path.join(snapshotFixturePath, 'describe.example'); - const results = snapshotHelper.getMetadata(filePath); - const allDescribe = [ - 'describe', - 'describe.only', - 'describe.skip', - 'fdescribe', - 'xdescribe', - ]; - const allAssertion = [ - 'fit', - 'it', - 'it.only', - 'it.skip', - 'test', - 'test.only', - 'test.skip', - 'xit', - 'xtest', - ]; - - const expectations = Object.create(null); - - allDescribe.forEach(describe => { - allAssertion.forEach(assertion => { - expectations[describe.toUpperCase() + ' ' + assertion + ' 1'] = { - assertion, - checked: false, - describe, - number: 1, - }; - - expectations[describe.toUpperCase() + ' ' + assertion + ' 2'] = { - assertion, - checked: false, - describe, - number: 2, - }; - }); - }); - - results.forEach(result => { - const check = expectations[result.name]; - check.checked = - result.content === `${check.number} ${check.assertion} ${check.describe}`; - }); - expect( - Object.keys(expectations) - .map(key => expectations[key]) - .filter(expectation => !expectation.checked).length, - ).toBe(0); -}); - -test('nested.example', () => { - const filePath = path.join(snapshotFixturePath, 'nested.example'); - const results = snapshotHelper.getMetadata(filePath); - expect(results[0].content).toBe('first nested'); - expect(results[1].content).toBe('second nested'); - - expect(results[0].name).toBe( - 'outer describe outer it inner describe inner it 1', - ); - expect(results[1].name).toBe( - 'outer describe outer it inner describe inner it 2', - ); - - expect(results[0].node.loc.start).toEqual({column: 21, line: 5}); - expect(results[0].node.loc.end).toEqual({column: 36, line: 5}); - expect(results[1].node.loc.start).toEqual({column: 21, line: 6}); - expect(results[1].node.loc.end).toEqual({column: 36, line: 6}); -}); diff --git a/packages/jest-editor-support/src/__tests__/test_reconciler.test.js b/packages/jest-editor-support/src/__tests__/test_reconciler.test.js deleted file mode 100644 index 04da6692ae9b..000000000000 --- a/packages/jest-editor-support/src/__tests__/test_reconciler.test.js +++ /dev/null @@ -1,213 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -import fs from 'fs'; -import path from 'path'; -import TestReconciler from '../test_reconciler'; -import type {TestFileAssertionStatus, TestAssertionStatus} from '../types'; - -const fixtures = path.resolve(__dirname, '../../../../fixtures'); - -function reconcilerWithFile( - parser: TestReconciler, - file: string, -): TestFileAssertionStatus[] { - const exampleJSON = fs.readFileSync(`${fixtures}/failing-jsons/${file}`); - const json = JSON.parse(exampleJSON.toString()); - if (!parser) console.error('no parser for ', file); - return parser.updateFileWithJestStatus(json); -} - -describe('Test Reconciler', () => { - let parser: TestReconciler; - let results: TestFileAssertionStatus[]; - - const dangerFilePath = - '/Users/orta/dev/projects/danger/' + - 'danger-js/source/ci_source/_tests/_travis.test.js'; - - describe('for a simple project', () => { - beforeAll(() => { - parser = new TestReconciler(); - results = reconcilerWithFile(parser, 'failing_jest_json.json'); - }); - - it('returns expected result for all test suites', () => { - expect(results.length).toEqual(5); - }); - it('passes a passing method', () => { - const testName = 'does not validate without josh'; - const status: any = parser.stateForTestAssertion( - dangerFilePath, - testName, - ); - expect(status.status).toEqual('KnownSuccess'); - expect(status.line).toBeNull(); - }); - - it('fails a failing method in the same file', () => { - const testName = - 'validates when all Travis environment' + - ' vars are set and Josh K says so'; - - const status: any = parser.stateForTestAssertion( - dangerFilePath, - testName, - ); - expect(status.status).toEqual('KnownFail'); - expect(status.line).toEqual(12); - const errorMessage = 'Expected value to be falsy, instead received true'; - expect(status.terseMessage).toEqual(errorMessage); - expect(status.shortMessage).toEqual(`Error: expect(received).toBeFalsy() - -Expected value to be falsy, instead received - true`); - }); - - it('skips a skipped method', () => { - const testName = 'does not pull it out of the env'; - const status: any = parser.stateForTestAssertion( - dangerFilePath, - testName, - ); - expect(status.status).toEqual('KnownSkip'); - expect(status.line).toBeNull(); - }); - }); - - describe('in a monorepo project', () => { - beforeEach(() => { - parser = new TestReconciler(); - results = reconcilerWithFile(parser, 'monorepo_root_1.json'); - }); - - it('did processed all test suits including the suites failed to run', () => { - expect(results.length).toEqual(8); - const failed = results.filter(r => r.status === 'KnownFail'); - expect(failed.length).toEqual(4); - //2 of them is failed suite, i.e. no assertions - expect( - failed.filter(r => !r.assertions || r.assertions.length === 0).length, - ).toEqual(2); - }); - it('did catch the passed tests', () => { - const succeededSuites = results.filter(r => r.status === 'KnownSuccess'); - expect(succeededSuites.length).toEqual(4); - - const succeededTests = results - .map(r => r.assertions || []) - // $FlowFixMe: Flow thinks the type is array from above, not the number passed as initial value - .reduce((sum: number, assertions: TestAssertionStatus[]) => { - const success = assertions.filter(a => a.status === 'KnownSuccess'); - return sum + success.length; - }, 0); - expect(succeededTests).toEqual(46); - }); - describe('when test updated', () => { - const targetTests = { - failedThenRemoved: [ - '/X/packages/Y-core/src/eth/__tests__/types.test.ts', - 'should fail', - ], - missingThenFailed: [ - '/X/packages/Y-app-vault/native/__tests__/index.ios.js', - 'testing jest with react-native', - ], - missingThenFixed: [ - '/X/packages/Y-app-vault/native/__tests__/index.ios.js', - 'renders correctly', - ], - passed: [ - '/X/packages/Y-keeper/src/redux/middlewares/__tests__/createGateMonitor.test.ts', - 'can log/profile doable async actions', - ], - }; - - function verifyTest(key: string, expectedStatus?: string) { - const test = parser.stateForTestAssertion( - targetTests[key][0], - targetTests[key][1], - ); - if (!test && !expectedStatus) { - return; - } - if (expectedStatus && test) { - expect(test.status).toEqual(expectedStatus); - return; - } - expect(key + ': ' + JSON.stringify(test)).toEqual(expectedStatus); // failed! - } - - it('verify before update occurred', () => { - verifyTest('missingThenFixed', undefined); - verifyTest('missingThenFailed', undefined); - verifyTest('failedThenRemoved', 'KnownFail'); - verifyTest('passed', 'KnownSuccess'); - }); - - it('new file can update existing result', () => { - //in file 2 we fixed 2 failed suites and removed 1 failed test - //let's check the failed tests are now passed, while the previously - //passed test should still be accessible - const results2 = reconcilerWithFile(parser, 'monorepo_root_2.json'); - expect(results2.length).toEqual(4); - - verifyTest('missingThenFixed', 'KnownSuccess'); - verifyTest('missingThenFailed', 'KnownFail'); - verifyTest('failedThenRemoved', undefined); - verifyTest('passed', 'KnownSuccess'); - }); - }); - }); -}); - -describe('Terse Messages', () => { - let parser: TestReconciler; - - beforeEach(() => { - parser = new TestReconciler(); - const _ = reconcilerWithFile(parser, 'failing_expects.json'); - }); - - it('handles shrinking a snapshot message', () => { - const file = - '/Users/orta/dev/projects/artsy/js/' + - 'libs/jest-snapshots-svg/src/_tests/example.test.ts'; - - const terseForTest = name => parser.stateForTestAssertion(file, name); - - let message = 'Expected value to equal: 2, Received: 1'; - let testName = 'numbers'; - expect(terseForTest(testName)).toHaveProperty('terseMessage', message); - - message = 'Expected value to equal: 2, Received: "1"'; - testName = 'string to numbers: numbers'; - expect(terseForTest(testName)).toHaveProperty('terseMessage', message); - - message = 'Expected value to equal: {"a": 2}, Received: {}'; - testName = 'objects'; - expect(terseForTest(testName)).toHaveProperty('terseMessage', message); - - message = 'Snapshot has changed'; - testName = 'snapshots'; - expect(terseForTest(testName)).toHaveProperty('terseMessage', message); - - message = 'Expected value to be greater than: 3, Received: 2'; - testName = 'greater than'; - expect(terseForTest(testName)).toHaveProperty('terseMessage', message); - - message = 'Expected value to be falsy, instead received 2'; - testName = 'falsy'; - expect(terseForTest(testName)).toHaveProperty('terseMessage', message); - - message = 'Expected value to be truthy, instead received null'; - testName = 'truthy'; - expect(terseForTest(testName)).toHaveProperty('terseMessage', message); - }); -}); diff --git a/packages/jest-editor-support/src/index.js b/packages/jest-editor-support/src/index.js deleted file mode 100644 index 146f57f90b6e..000000000000 --- a/packages/jest-editor-support/src/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -import * as Process from './Process'; - -import ProjectWorkspace from './project_workspace'; -import Runner from './Runner'; -import Settings from './Settings'; -import Snapshot from './Snapshot'; -import {Expect, ItBlock, Node} from './parsers/parser_nodes'; -import {parse} from './parsers/babylon_parser'; -import TestReconciler from './test_reconciler'; - -module.exports = { - Expect, - ItBlock, - Node, - Process, - ProjectWorkspace, - Runner, - Settings, - Snapshot, - TestReconciler, - parse, -}; diff --git a/packages/jest-editor-support/src/parsers/babylon_parser.js b/packages/jest-editor-support/src/parsers/babylon_parser.js deleted file mode 100644 index 445a64621549..000000000000 --- a/packages/jest-editor-support/src/parsers/babylon_parser.js +++ /dev/null @@ -1,171 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -import {readFileSync} from 'fs'; - -import {parse as babylonParse} from 'babylon'; -import {Expect, ItBlock} from './parser_nodes'; -import type {File as BabylonFile} from 'babylon'; - -export type BabylonParserResult = { - expects: Array, - itBlocks: Array, -}; - -export const getASTfor = (file: string): BabylonFile => { - const data = readFileSync(file).toString(); - const config = {plugins: ['*'], sourceType: 'module'}; - return babylonParse(data, config); -}; - -export const parse = (file: string): BabylonParserResult => { - const itBlocks: ItBlock[] = []; - const expects: Expect[] = []; - - const ast = getASTfor(file); - - // An `it`/`test` was found in the AST - // So take the AST node and create an object for us - // to store for later usage - const foundItNode = (node: any, file: string) => { - const block = new ItBlock(); - block.name = node.expression.arguments[0].value; - block.start = node.loc.start; - block.end = node.loc.end; - - block.start.column += 1; - - block.file = file; - itBlocks.push(block); - }; - - // An `expect` was found in the AST - // So take the AST node and create an object for us - // to store for later usage - const foundExpectNode = (node: any, file: string) => { - const expect = new Expect(); - expect.start = node.loc.start; - expect.end = node.loc.end; - - expect.start.column += 1; - expect.end.column += 1; - - expect.file = file; - expects.push(expect); - }; - - const isFunctionCall = node => - node.type === 'ExpressionStatement' && - node.expression && - node.expression.type === 'CallExpression'; - - const isFunctionDeclaration = (nodeType: string) => - nodeType === 'ArrowFunctionExpression' || nodeType === 'FunctionExpression'; - - // Pull out the name of a CallExpression (describe/it) - // handle cases where it's a member expression (.only) - const getNameForNode = node => { - if (!isFunctionCall(node)) { - return false; - } - let name = - node && node.expression && node.expression.callee - ? node.expression.callee.name - : undefined; - if ( - !name && - node && - node.expression && - node.expression.callee && - node.expression.callee.object - ) { - name = node.expression.callee.object.name; - } - return name; - }; - - // When given a node in the AST, does this represent - // the start of an it/test block? - const isAnIt = node => { - const name = getNameForNode(node); - return name === 'it' || name === 'fit' || name === 'test'; - }; - - // When given a node in the AST, does this represent - // the start of an expect expression? - const isAnExpect = node => { - if (!isFunctionCall(node)) { - return false; - } - let name = ''; - let element = node && node.expression ? node.expression.callee : undefined; - while (!name && element) { - name = element.name; - // Because expect may have accessors tacked on (.to.be) or nothing - // (expect()) we have to check multiple levels for the name - element = element.object || element.callee; - } - return name === 'expect'; - }; - - // A recursive AST parser - const searchNodes = (root: any, file: string) => { - // Look through the node's children - for (const node in root.body) { - if (!root.body.hasOwnProperty(node)) { - return; - } - - // Pull out the node - const element = root.body[node]; - - if (isAnIt(element)) { - foundItNode(element, file); - } else if (isAnExpect(element)) { - foundExpectNode(element, file); - } else if (element && element.type === 'VariableDeclaration') { - element.declarations - .filter( - declaration => - declaration.init && isFunctionDeclaration(declaration.init.type), - ) - .forEach(declaration => searchNodes(declaration.init.body, file)); - } else if ( - element && - element.type === 'ExpressionStatement' && - element.expression && - element.expression.type === 'AssignmentExpression' && - element.expression.right && - isFunctionDeclaration(element.expression.right.type) - ) { - searchNodes(element.expression.right.body, file); - } else if ( - element.type === 'ReturnStatement' && - element.argument.arguments - ) { - element.argument.arguments - .filter(argument => isFunctionDeclaration(argument.type)) - .forEach(argument => searchNodes(argument.body, file)); - } - - if (isFunctionCall(element)) { - element.expression.arguments - .filter(argument => isFunctionDeclaration(argument.type)) - .forEach(argument => searchNodes(argument.body, file)); - } - } - }; - - searchNodes(ast['program'], file); - - return { - expects, - itBlocks, - }; -}; diff --git a/packages/jest-editor-support/src/parsers/parser_nodes.js b/packages/jest-editor-support/src/parsers/parser_nodes.js deleted file mode 100644 index 08d7dcfb95c3..000000000000 --- a/packages/jest-editor-support/src/parsers/parser_nodes.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -import type {Location} from '../types'; - -export class Node { - start: Location; - end: Location; - file: string; -} - -export class Expect extends Node {} - -export class ItBlock extends Node { - name: string; -} diff --git a/packages/jest-editor-support/src/project_workspace.js b/packages/jest-editor-support/src/project_workspace.js deleted file mode 100644 index a092ea6a668e..000000000000 --- a/packages/jest-editor-support/src/project_workspace.js +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -/** - * Represents the project that the extension is running on and it's state - */ -export default class ProjectWorkspace { - /** - * The path to the root of the project's workspace - * - * @type {string} - */ - rootPath: string; - - /** - * The path to Jest, this is normally a file path like - * `node_modules/.bin/jest` but you should not make the assumption that - * it is always a direct file path, as in a create-react app it would look - * like `npm test --`. - * - * This means when launching a process, you will need to split on the first - * space, and then move any other args into the args of the process. - * - * @type {string} - */ - pathToJest: string; - - /** - * Path to a local Jest config file. - * - * @type {string} - */ - pathToConfig: string; - - /** - * local Jest major release version, as the runner could run against - * any version of Jest. - * - * @type {number} - */ - localJestMajorVersion: number; - - /** - * Whether test coverage should be (automatically) collected. - * - * @type {boolean} - */ - collectCoverage: ?boolean; - - /** - * if to output more information for debugging purpose. Default is false. - * - * @type {boolean} - */ - debug: ?boolean; - - constructor( - rootPath: string, - pathToJest: string, - pathToConfig: string, - localJestMajorVersion: number, - collectCoverage: ?boolean, - debug: ?boolean, - ) { - this.rootPath = rootPath; - this.pathToJest = pathToJest; - this.pathToConfig = pathToConfig; - this.localJestMajorVersion = localJestMajorVersion; - this.collectCoverage = collectCoverage; - this.debug = debug; - } -} diff --git a/packages/jest-editor-support/src/test_reconciler.js b/packages/jest-editor-support/src/test_reconciler.js deleted file mode 100644 index cdfad3ba37ac..000000000000 --- a/packages/jest-editor-support/src/test_reconciler.js +++ /dev/null @@ -1,166 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -import type { - TestFileAssertionStatus, - TestAssertionStatus, - TestReconciliationState, -} from './types'; - -import type { - FormattedAssertionResult, - FormattedTestResults, -} from 'types/TestResult'; - -import path from 'path'; - -/** - * You have a Jest test runner watching for changes, and you have - * an extension that wants to know where to show errors after file parsing. - * - * This class represents the state between runs, keeping track of passes/fails - * at a file level, generating useful error messages and providing a nice API. - */ -export default class TestReconciler { - fileStatuses: {[key: string]: TestFileAssertionStatus}; - - constructor() { - this.fileStatuses = {}; - } - - // the processed test results will be returned immediately instead of saved in - // instance properties. This is 1) to prevent race condition 2) the data is already - // stored in the this.fileStatuses, no dup is better 3) client will most likely need to process - // all the results anyway. - updateFileWithJestStatus( - results: FormattedTestResults, - ): TestFileAssertionStatus[] { - // Loop through all files inside the report from Jest - const statusList: TestFileAssertionStatus[] = []; - results.testResults.forEach(file => { - // Did the file pass/fail? - const status = this.statusToReconcilationState(file.status); - // Create our own simpler representation - const fileStatus: TestFileAssertionStatus = { - assertions: this.mapAssertions(file.name, file.assertionResults), - file: file.name, - message: file.message, - status, - }; - this.fileStatuses[file.name] = fileStatus; - statusList.push(fileStatus); - }); - return statusList; - } - - // A failed test also contains the stack trace for an `expect` - // we don't get this as structured data, but what we get - // is useful enough to make it for ourselves - - mapAssertions( - filename: string, - assertions: Array, - ): Array { - // Is it jest < 17? e.g. Before I added this to the JSON - if (!assertions) { - return []; - } - - // Change all failing assertions into structured data - return assertions.map(assertion => { - // Failure messages seems to always be an array of one item - const message = assertion.failureMessages && assertion.failureMessages[0]; - let short = null; - let terse = null; - let line = null; - if (message) { - // Just the first line, with little whitespace - short = message.split(' at', 1)[0].trim(); - // this will show inline, so we want to show very little - terse = this.sanitizeShortErrorMessage(short); - line = this.lineOfError(message, filename); - } - return { - line, - message: message || '', - shortMessage: short, - status: this.statusToReconcilationState(assertion.status), - terseMessage: terse, - title: assertion.title, - }; - }); - } - - // Do everything we can to try make a one-liner from the error report - sanitizeShortErrorMessage(string: string): string { - if (string.includes('does not match stored snapshot')) { - return 'Snapshot has changed'; - } - - if (string.includes('New snapshot was not written')) { - return 'New snapshot is ready to write'; - } - - return string - .split('\n') - .splice(2) - .join('') - .replace(/\s\s+/g, ' ') - .replace('Received:', ', Received:') - .split('Difference:')[0]; - } - - // Pull the line out from the stack trace - lineOfError(message: string, filePath: string): ?number { - const filename = path.basename(filePath); - const restOfTrace = message.split(filename, 2)[1]; - return restOfTrace ? parseInt(restOfTrace.split(':')[1], 10) : null; - } - - statusToReconcilationState(status: string): TestReconciliationState { - switch (status) { - case 'passed': - return 'KnownSuccess'; - case 'failed': - return 'KnownFail'; - case 'pending': - return 'KnownSkip'; - default: - return 'Unknown'; - } - } - - stateForTestFile(file: string): TestReconciliationState { - const results = this.fileStatuses[file]; - if (!results) { - return 'Unknown'; - } - return results.status; - } - - assertionsForTestFile(file: string): TestAssertionStatus[] | null { - const results = this.fileStatuses[file]; - return results ? results.assertions : null; - } - - stateForTestAssertion( - file: string, - name: string, - ): TestAssertionStatus | null { - const results = this.fileStatuses[file]; - if (!results || !results.assertions) { - return null; - } - const assertion = results.assertions.find(a => a.title === name); - if (!assertion) { - return null; - } - return assertion; - } -} diff --git a/packages/jest-editor-support/src/types.js b/packages/jest-editor-support/src/types.js deleted file mode 100644 index fdabbdb65c0b..000000000000 --- a/packages/jest-editor-support/src/types.js +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -export type Location = { - column: number, - line: number, -}; - -export type SpawnOptions = { - shell?: boolean, -}; - -import type {ChildProcess} from 'child_process'; -import type ProjectWorkspace from './project_workspace'; - -export type Options = { - createProcess?: ( - workspace: ProjectWorkspace, - args: Array, - options?: SpawnOptions, - ) => ChildProcess, - noColor?: boolean, - testNamePattern?: string, - testFileNamePattern?: string, - shell?: boolean, -}; - -/** - * Did the thing pass, fail or was it not run? - */ -export type TestReconciliationState = - | 'Unknown' // The file has not changed, so the watcher didn't hit it - | 'KnownFail' // Definitely failed - | 'KnownSuccess' // Definitely passed - | 'KnownSkip'; // Definitely skipped - -/** - * The Jest Extension's version of a status for - * whether the file passed or not - * - */ -export type TestFileAssertionStatus = { - file: string, - message: string, - status: TestReconciliationState, - assertions: Array | null, -}; - -/** - * The Jest Extension's version of a status for - * individual assertion fails - * - */ -export type TestAssertionStatus = { - title: string, - status: TestReconciliationState, - message: string, - shortMessage: ?string, - terseMessage: ?string, - line: ?number, -}; - -export type JestTotalResultsMeta = { - noTestsFound: boolean, -}; - -export const messageTypes = { - noTests: 1, - testResults: 3, - unknown: 0, - watchUsage: 2, -}; - -export type MessageType = number; diff --git a/packages/jest-test-typescript-parser/.npmignore b/packages/jest-test-typescript-parser/.npmignore deleted file mode 100644 index 85e48fe7b0a4..000000000000 --- a/packages/jest-test-typescript-parser/.npmignore +++ /dev/null @@ -1,3 +0,0 @@ -**/__mocks__/** -**/__tests__/** -src diff --git a/packages/jest-test-typescript-parser/package.json b/packages/jest-test-typescript-parser/package.json deleted file mode 100644 index 7f0674177eac..000000000000 --- a/packages/jest-test-typescript-parser/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "jest-test-typescript-parser", - "version": "23.6.0", - "repository": { - "type": "git", - "url": "https://github.com/facebook/jest.git" - }, - "license": "MIT", - "main": "build/index.js", - "dependencies": { - "jest-editor-support": "^23.6.0", - "typescript": "^2.5.3" - } -} diff --git a/packages/jest-test-typescript-parser/src/__tests__/type_script_parser.test.js b/packages/jest-test-typescript-parser/src/__tests__/type_script_parser.test.js deleted file mode 100644 index 824e125a6799..000000000000 --- a/packages/jest-test-typescript-parser/src/__tests__/type_script_parser.test.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -'use strict'; - -import {parse} from '../type_script_parser'; -import {parserTests} from '../../../../fixtures/parser_tests'; - -parserTests(parse); diff --git a/packages/jest-test-typescript-parser/src/index.js b/packages/jest-test-typescript-parser/src/index.js deleted file mode 100644 index 3f0dd5dc18b1..000000000000 --- a/packages/jest-test-typescript-parser/src/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -import {parse as babylonParser, ItBlock, Expect} from 'jest-editor-support'; -import * as TypeScriptParser from './type_script_parser'; - -export type ParserReturn = { - itBlocks: Array, - expects: Array, -}; - -/** - * Converts the file into an AST, then passes out a - * collection of it and expects. - */ -function parse(file: string): ParserReturn { - if (file.match(/\.tsx?$/)) { - return TypeScriptParser.parse(file); - } else { - return babylonParser(file); - } -} - -module.exports = { - TypeScriptParser, - parse, -}; diff --git a/packages/jest-test-typescript-parser/src/type_script_parser.js b/packages/jest-test-typescript-parser/src/type_script_parser.js deleted file mode 100644 index b045cfb19b74..000000000000 --- a/packages/jest-test-typescript-parser/src/type_script_parser.js +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -import {readFileSync} from 'fs'; - -import ts from 'typescript'; -import {Expect, ItBlock, Node} from 'jest-editor-support'; - -export function parse(file: string) { - const sourceFile = ts.createSourceFile( - file, - readFileSync(file).toString(), - ts.ScriptTarget.ES3, - ); - - const itBlocks: Array = []; - const expects: Array = []; - function searchNodes(node: ts.Node) { - if (node.kind === ts.SyntaxKind.CallExpression) { - let {text} = node.expression; - if (!text) { - // Property access (it.only) - text = node.expression.expression.text; - } - if (text === 'it' || text === 'test' || text === 'fit') { - const position = getNode(sourceFile, node, new ItBlock()); - position.name = node.arguments[0].text; - itBlocks.push(position); - } else { - let element = node.expression; - let expectText = ''; - while (element && !expectText) { - expectText = element.text; - element = element.expression; - } - if (expectText === 'expect') { - const position = getNode(sourceFile, node, new Expect()); - if ( - !expects.some( - e => - e.start.line === position.start.line && - e.start.column === position.start.column, - ) - ) { - expects.push(position); - } - } - } - } - ts.forEachChild(node, searchNodes); - } - - ts.forEachChild(sourceFile, searchNodes); - return { - expects, - itBlocks, - }; -} - -function getNode( - file: ts.SourceFile, - expression: ts.CallExpression, - node: T, -): T { - const start = file.getLineAndCharacterOfPosition(expression.getStart(file)); - // TypeScript parser is 0 based, so we have to increment by 1 to normalize - node.start = { - column: start.character + 1, - line: start.line + 1, - }; - const end = file.getLineAndCharacterOfPosition(expression.getEnd()); - node.end = { - column: end.character + 1, - line: end.line + 1, - }; - node.file = file.fileName; - return node; -} diff --git a/yarn.lock b/yarn.lock index eec0d052fed6..98c800b27e84 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2794,7 +2794,7 @@ babel-template@^6.16.0, babel-template@^6.24.1, babel-template@^6.26.0: babylon "^6.18.0" lodash "^4.17.4" -babel-traverse@^6.0.0, babel-traverse@^6.14.1, babel-traverse@^6.18.0, babel-traverse@^6.24.1, babel-traverse@^6.25.0, babel-traverse@^6.26.0: +babel-traverse@^6.0.0, babel-traverse@^6.18.0, babel-traverse@^6.24.1, babel-traverse@^6.25.0, babel-traverse@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.26.0.tgz#46a9cbd7edcc62c8e5c064e2d2d8d0f4035766ee" integrity sha1-RqnL1+3MYsjlwGTi0tjQ9ANXZu4= @@ -2819,7 +2819,7 @@ babel-types@^6.0.0, babel-types@^6.18.0, babel-types@^6.19.0, babel-types@^6.24. lodash "^4.17.4" to-fast-properties "^1.0.3" -babylon@^6.14.1, babylon@^6.15.0, babylon@^6.17.4, babylon@^6.18.0: +babylon@^6.15.0, babylon@^6.17.4, babylon@^6.18.0: version "6.18.0" resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3" integrity sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ== @@ -13407,7 +13407,7 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@*, typescript@^2.2.2, typescript@^2.5.3: +typescript@*, typescript@^2.2.2: version "2.9.2" resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.9.2.tgz#1cbf61d05d6b96269244eb6a3bce4bd914e0f00c" integrity sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==