Skip to content

Commit

Permalink
Preserve scripts/test.js after ejecting (facebook#715)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon authored and feiqitian committed Oct 25, 2016
1 parent 9d96d6f commit 7a0f3d1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/react-scripts/scripts/eject.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ prompt(
path.join('config', 'jest', 'FileStub.js'),
path.join('scripts', 'build.js'),
path.join('scripts', 'start.js'),
path.join('scripts', 'test.js'),
path.join('scripts', 'utils', 'checkRequiredFiles.js'),
path.join('scripts', 'utils', 'chrome.applescript'),
path.join('scripts', 'utils', 'getClientEnvironment.js'),
Expand Down Expand Up @@ -98,7 +99,6 @@ prompt(
delete appPackage.scripts['eject'];
Object.keys(appPackage.scripts).forEach(function (key) {
appPackage.scripts[key] = appPackage.scripts[key]
.replace(/react-scripts test/g, 'jest --watch')
.replace(/react-scripts (\w+)/g, 'node scripts/$1.js');
});

Expand Down
7 changes: 6 additions & 1 deletion packages/react-scripts/scripts/test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @remove-on-eject-begin
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
Expand All @@ -6,6 +7,7 @@
* 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.
*/
// @remove-on-eject-end

process.env.NODE_ENV = 'test';
process.env.PUBLIC_URL = '';
Expand All @@ -16,7 +18,6 @@ process.env.PUBLIC_URL = '';
// https://github.com/motdotla/dotenv
require('dotenv').config({silent: true});

const createJestConfig = require('./utils/createJestConfig');
const jest = require('jest');
const path = require('path');
const paths = require('../config/paths');
Expand All @@ -28,10 +29,14 @@ if (!process.env.CI) {
argv.push('--watch');
}

// @remove-on-eject-begin
// This is not necessary after eject because we embed config into package.json.
const createJestConfig = require('./utils/createJestConfig');
argv.push('--config', JSON.stringify(createJestConfig(
relativePath => path.resolve(__dirname, '..', relativePath),
path.resolve(paths.appSrc, '..'),
false
)));
// @remove-on-eject-end

jest.run(argv);

0 comments on commit 7a0f3d1

Please sign in to comment.