diff --git a/integration-tests/__tests__/multi_project_runner.test.js b/integration-tests/__tests__/multi_project_runner.test.js index ecd1123667c7..7d5c7440f8a4 100644 --- a/integration-tests/__tests__/multi_project_runner.test.js +++ b/integration-tests/__tests__/multi_project_runner.test.js @@ -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)); @@ -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: '/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: '/../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: '/../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: '/../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', ); @@ -91,6 +108,9 @@ test('can pass projects or global config', () => { 'global_config.js': ` module.exports = { projects: ['project1/', 'project2/', 'project3/'], + haste: { + hasteImplModulePath: '/hasteImpl.js', + }, }; `, }); @@ -102,6 +122,8 @@ test('can pass projects or global config', () => { 'project1', 'project2', 'project3', + '--config', + 'base_config.js', ])); const result1 = extractSummary(stderr); @@ -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, [ @@ -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': '{}', });