nx/packages/jest/src/utils/config/functions.spec.ts
Leosvel Pérez Espinosa c0aa245d9c
feat(testing): remove deprecated getJestProjects (#30844)
Remove the deprecated function `getJestProjects`.

BREAKING CHANGE: The previously deprecated `getJestProjects` function
was removed in favor of `getJestProjectsAsync`.
2025-04-25 09:12:13 -04:00

46 lines
1.0 KiB
TypeScript

import { createTree } from '@nx/devkit/testing';
import { jestConfigObject, jestConfigObjectAst } from './functions';
describe('jestConfigObject', () => {
describe('module.exports', () => {
it('should work for basic cases', () => {
const tree = createTree();
tree.write(
'jest.config.js',
`
module.exports = {
foo: 'bar'
};
`
);
expect(jestConfigObject(tree, 'jest.config.js')).toEqual({
foo: 'bar',
});
});
});
describe('export default', () => {
it('should work for basic cases', () => {
const content = `
export default {
abc: 'xyz'
}`;
expect(jestConfigObjectAst(content).getText()).toMatchSnapshot();
});
it('should handle spread assignments', () => {
const content = `
import { nxPreset } from '@nx/jest/preset';
export default {
...nxPreset,
abc: 'xyz'
}`;
expect(jestConfigObjectAst(content).getText()).toMatchSnapshot();
});
});
});