chore(core): clean up task hasher spec (#18230)

This commit is contained in:
Jason Jean 2023-07-20 17:45:16 -04:00 committed by GitHub
parent 2cf039783a
commit 49a95800bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,14 @@
// This must come before the Hasher import // This must come before the Hasher import
import { DependencyType } from '../config/project-graph'; import { DependencyType } from '../config/project-graph';
import { vol } from 'memfs';
import {
expandNamedInput,
filterUsingGlobPatterns,
Hash,
InProcessTaskHasher,
} from './task-hasher';
import { fileHasher } from './file-hasher';
import { withEnvironmentVariables } from '../../internal-testing-utils/with-environment';
jest.mock('../utils/workspace-root', () => { jest.mock('../utils/workspace-root', () => {
return { return {
@ -20,16 +29,6 @@ jest.mock('../plugins/js/utils/typescript', () => ({
.mockImplementation(() => '/root/tsconfig.base.json'), .mockImplementation(() => '/root/tsconfig.base.json'),
})); }));
import { vol } from 'memfs';
import {
expandNamedInput,
filterUsingGlobPatterns,
Hash,
InProcessTaskHasher,
} from './task-hasher';
import { fileHasher } from './file-hasher';
import { withEnvironmentVariables } from '../../internal-testing-utils/with-environment';
describe('TaskHasher', () => { describe('TaskHasher', () => {
const packageJson = { const packageJson = {
name: 'nrwl', name: 'nrwl',
@ -1284,27 +1283,25 @@ describe('TaskHasher', () => {
); );
const computeTaskHash = async (hasher, appName) => { const computeTaskHash = async (hasher, appName) => {
const hashAppA = await hasher.hashTask({ return await hasher.hashTask({
target: { project: appName, target: 'build' }, target: { project: appName, target: 'build' },
id: `${appName}-build`, id: `${appName}-build`,
overrides: { prop: 'prop-value' }, overrides: { prop: 'prop-value' },
}); });
return hashAppA.value;
}; };
const hasher1 = createHasher(); const hasher1 = createHasher();
const hasAppA1 = await computeTaskHash(hasher1, 'appA'); const hashAppA1 = await computeTaskHash(hasher1, 'appA');
const hashAppB1 = await computeTaskHash(hasher1, 'appB'); const hashAppB1 = await computeTaskHash(hasher1, 'appB');
const hasher2 = createHasher(); const hasher2 = createHasher();
const hashAppB2 = await computeTaskHash(hasher2, 'appB'); const hashAppB2 = await computeTaskHash(hasher2, 'appB');
const hasAppA2 = await computeTaskHash(hasher2, 'appA'); const hashAppA2 = await computeTaskHash(hasher2, 'appA');
expect(hashAppB1).toEqual(hashAppB2); expect(hashAppB1).toEqual(hashAppB2);
expect(hasAppA1).toEqual(hasAppA2); expect(hashAppA1).toEqual(hashAppA2);
}); });
it('should not hash when nx:run-commands executor', async () => { it('should not hash when nx:run-commands executor', async () => {