Skip to content

Commit

Permalink
Fixed integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
rubennorte committed May 1, 2018
1 parent e7b32f6 commit ee36091
Showing 1 changed file with 43 additions and 21 deletions.
64 changes: 43 additions & 21 deletions integration-tests/__tests__/multi_project_runner.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ const DIR = path.resolve(os.tmpdir(), 'multi_project_runner_test');

SkipOnWindows.suite();

const fileContentWithProvidesModule = name => `/*
* @providesModule ${name}
*/
module.exports = {};
`;
const SAMPLE_FILE_CONTENT = 'module.exports = {};';

beforeEach(() => cleanup(DIR));
afterEach(() => cleanup(DIR));
Expand Down Expand Up @@ -58,29 +53,51 @@ test('--listTests doesnt duplicate the test files', () => {
test('can pass projects or global config', () => {
writeFiles(DIR, {
'.watchmanconfig': '',
'base_config.js': `
module.exports = {
haste: {
hasteImplModulePath: '<rootDir>/hasteImpl.js',
},
};
`,
'hasteImpl.js': `
module.exports = {
getHasteName(path) {
return path
.substr(path.lastIndexOf('/') + 1)
.replace(/\.js$/, '');
},
};
`,
'package.json': '{}',
'project1/__tests__/file1.test.js': `
const file1 = require('file1');
test('file1', () => {});
`,
'project1/file1.js': fileContentWithProvidesModule('file1'),
'project1/jest.config.js': `module.exports = {rootDir: './', displayName: 'BACKEND'}`,
'project1/file1.js': SAMPLE_FILE_CONTENT,
'project1/jest.config.js': `module.exports = {rootDir: './', displayName: 'BACKEND', haste: {
hasteImplModulePath: '<rootDir>/../hasteImpl.js',
},}`,
'project2/__tests__/file1.test.js': `
const file1 = require('file1');
test('file1', () => {});
`,
'project2/file1.js': fileContentWithProvidesModule('file1'),
'project2/jest.config.js': `module.exports = {rootDir: './'}`,
'project2/file1.js': SAMPLE_FILE_CONTENT,
'project2/jest.config.js': `module.exports = {rootDir: './', haste: {
hasteImplModulePath: '<rootDir>/../hasteImpl.js',
},}`,
'project3/__tests__/file1.test.js': `
const file1 = require('file1');
test('file1', () => {});
`,
'project3/file1.js': fileContentWithProvidesModule('file1'),
'project3/jest.config.js': `module.exports = {rootDir: './', displayName: 'UI'}`,
'project3/file1.js': SAMPLE_FILE_CONTENT,
'project3/jest.config.js': `module.exports = {rootDir: './', displayName: 'UI', haste: {
hasteImplModulePath: '<rootDir>/../hasteImpl.js',
},}`,
});
let stderr;

({stderr} = runJest(DIR, ['--no-watchman']));
({stderr} = runJest(DIR, ['--no-watchman', '--config', 'base_config.js']));
expect(stderr).toMatch(
'The name `file1` was looked up in the Haste module map. It cannot be resolved, because there exists several different files',
);
Expand All @@ -91,6 +108,9 @@ test('can pass projects or global config', () => {
'global_config.js': `
module.exports = {
projects: ['project1/', 'project2/', 'project3/'],
haste: {
hasteImplModulePath: '<rootDir>/hasteImpl.js',
},
};
`,
});
Expand All @@ -102,6 +122,8 @@ test('can pass projects or global config', () => {
'project1',
'project2',
'project3',
'--config',
'base_config.js',
]));

const result1 = extractSummary(stderr);
Expand Down Expand Up @@ -129,16 +151,16 @@ test('"No tests found" message for projects', () => {
'.watchmanconfig': '',
'package.json': '{}',
'project1/__tests__/file1.test.js': `
const file1 = require('file1');
const file1 = require('../file1');
test('file1', () => {});
`,
'project1/file1.js': fileContentWithProvidesModule('file1'),
'project1/file1.js': SAMPLE_FILE_CONTENT,
'project1/jest.config.js': `module.exports = {rootDir: './'}`,
'project2/__tests__/file1.test.js': `
const file1 = require('file1');
const file1 = require('../file1');
test('file1', () => {});
`,
'project2/file1.js': fileContentWithProvidesModule('file1'),
'project2/file1.js': SAMPLE_FILE_CONTENT,
'project2/jest.config.js': `module.exports = {rootDir: './'}`,
});
const {stdout: verboseOutput} = runJest(DIR, [
Expand Down Expand Up @@ -173,16 +195,16 @@ test('projects can be workspaces with non-JS/JSON files', () => {
'packages/README.md': '# Packages README',
'packages/project1/README.md': '# Project1 README',
'packages/project1/__tests__/file1.test.js': `
const file1 = require('file1');
const file1 = require('../file1');
test('file1', () => {});
`,
'packages/project1/file1.js': fileContentWithProvidesModule('file1'),
'packages/project1/file1.js': SAMPLE_FILE_CONTENT,
'packages/project1/package.json': '{}',
'packages/project2/__tests__/file2.test.js': `
const file2 = require('file2');
const file2 = require('../file2');
test('file2', () => {});
`,
'packages/project2/file2.js': fileContentWithProvidesModule('file2'),
'packages/project2/file2.js': SAMPLE_FILE_CONTENT,
'packages/project2/package.json': '{}',
});

Expand Down

0 comments on commit ee36091

Please sign in to comment.