Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
avoid reaching into build
  • Loading branch information
SimenB committed Jan 28, 2023
commit 655c9534957a4efc751b9bb651f20dc0d473ceb9
11 changes: 6 additions & 5 deletions packages/jest-cli/src/init/__tests__/init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ import init from '../';
const {JEST_CONFIG_EXT_ORDER} = constants;

jest.mock('prompts');
jest.mock(
'../../../../jest-config/build/getCacheDirectory',
() => () => '/tmp/jest',
);
jest.mock('path', () => ({
...jest.requireActual<typeof import('path')>('path'),
sep: '/',
Expand Down Expand Up @@ -52,7 +48,12 @@ describe('init', () => {

const writtenJestConfig = jest.mocked(writeFileSync).mock.calls[0][1];

expect(writtenJestConfig).toMatchSnapshot();
expect(
writtenJestConfig.replace(
/\/\/ cacheDirectory: .*,/,
'// cacheDirectory: "/tmp/jest",',
),
).toMatchSnapshot();

const evaluatedConfig = eval(writtenJestConfig as string) as Record<
string,
Expand Down
8 changes: 7 additions & 1 deletion packages/jest-core/src/__tests__/watch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,13 @@ describe('Watch mode flows', () => {

beforeEach(() => {
isInteractive = true;
jest.doMock('jest-util/build/isInteractive', () => isInteractive);
jest.doMock('jest-util', () => {
const original = jest.requireActual('jest-util');
return {
...original,
isInteractive: () => isInteractive,
};
});
watch = require('../watch').default;
const config = {
rootDir: __dirname,
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-jasmine2/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export default async function jasmine2(

runtime
.requireInternalModule<typeof import('./jestExpect')>(
path.resolve(__dirname, './jestExpect.js'),
require.resolve('./jestExpect.js'),
)
.default({expand: globalConfig.expand});

Expand All @@ -165,7 +165,7 @@ export default async function jasmine2(

const snapshotState: SnapshotState = await runtime
.requireInternalModule<typeof import('./setup_jest_globals')>(
path.resolve(__dirname, './setup_jest_globals.js'),
require.resolve('./setup_jest_globals.js'),
)
.default({
config,
Expand Down