chore(js): update js plugin unit tests to use "as-provided" option when generating apps/libs (#18894)

This commit is contained in:
Jack Hsu 2023-08-29 16:17:06 -04:00 committed by GitHub
parent da2a08e575
commit 74c812e2e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 251 additions and 191 deletions

View File

@ -22,9 +22,9 @@ describe('convert to swc', () => {
};
beforeAll(() => {
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
tree.write('/apps/.gitignore', '');
tree.write('/libs/.gitignore', '');
tree = createTreeWithEmptyWorkspace();
tree.write('/.gitignore', '');
tree.write('/.gitignore', '');
});
it('should convert tsc to swc', async () => {
@ -32,6 +32,7 @@ describe('convert to swc', () => {
...defaultLibGenerationOptions,
name: 'tsc-lib',
bundler: 'tsc',
projectNameAndRootFormat: 'as-provided',
});
expect(
@ -49,7 +50,7 @@ describe('convert to swc', () => {
)
).toEqual(true);
expect(tree.read('package.json', 'utf-8')).toContain('@swc/core');
expect(tree.read('libs/tsc-lib/package.json', 'utf-8')).toContain(
expect(tree.read('tsc-lib/package.json', 'utf-8')).toContain(
'@swc/helpers'
);
});

View File

@ -23,13 +23,13 @@ if (swcJestConfig.swcrc === undefined) {
module.exports = {
displayName: 'my-lib',
preset: '../../jest.preset.js',
preset: '../jest.preset.js',
transform: {
'^.+\\\\.[tj]s$': ['@swc/jest', swcJestConfig],
},
moduleFileExtensions: ['ts', 'js', 'html'],
testEnvironment: 'jsdom',
coverageDirectory: '../../coverage/libs/my-lib',
coverageDirectory: '../coverage/my-lib',
};
"
`;

File diff suppressed because it is too large Load Diff

View File

@ -18,14 +18,14 @@ describe('explicitly-set-projects-to-update-buildable-deps migration', () => {
let tree: Tree;
beforeEach(() => {
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
tree = createTreeWithEmptyWorkspace();
});
it.each(['@nx/js:swc', '@nrwl/js:swc', '@nx/js:tsc', '@nrwl/js:tsc'])(
'should set updateBuildableProjectDepsInPackageJson option to "true" when not specified in target using "%s"',
async (executor) => {
addProject(tree, 'lib1', {
root: 'libs/lib1',
root: 'lib1',
projectType: 'library',
targets: { build: { executor, options: {} } },
});
@ -43,7 +43,7 @@ describe('explicitly-set-projects-to-update-buildable-deps migration', () => {
'should set updateBuildableProjectDepsInPackageJson option to "true" when target has no options object defined using "%s"',
async (executor) => {
addProject(tree, 'lib1', {
root: 'libs/lib1',
root: 'lib1',
projectType: 'library',
targets: { build: { executor } },
});
@ -61,7 +61,7 @@ describe('explicitly-set-projects-to-update-buildable-deps migration', () => {
'should not overwrite updateBuildableProjectDepsInPackageJson option when it is specified in target using "%s"',
async (executor) => {
addProject(tree, 'lib1', {
root: 'libs/lib1',
root: 'lib1',
projectType: 'library',
targets: {
build: {
@ -82,7 +82,7 @@ describe('explicitly-set-projects-to-update-buildable-deps migration', () => {
it('should not update targets using other executors', async () => {
const originalProjectConfig: ProjectConfiguration = {
root: 'libs/lib1',
root: 'lib1',
projectType: 'library',
targets: {
build: {