fix(@schematics/angular): remove vscode testing configurations for minimal workspaces

Remove the `ng test` VS Code task and `npm test` VS Code launch configuration from the workspace
when building minimal workspaces.

Fixes #23360
This commit is contained in:
Julien Marcou 2022-06-14 23:38:00 +02:00 committed by Alan Agius
parent b06ae55140
commit 7cbbf2f2ba
3 changed files with 30 additions and 4 deletions

View File

@ -8,13 +8,13 @@
"request": "launch",
"preLaunchTask": "npm: start",
"url": "http://localhost:4200/"
},
}<% if (!minimal) { %>,
{
"name": "ng test",
"type": "chrome",
"request": "launch",
"preLaunchTask": "npm: test",
"url": "http://localhost:9876/debug.html"
}
}<% } %>
]
}

View File

@ -19,7 +19,7 @@
}
}
}
},
}<% if (!minimal) { %>,
{
"type": "npm",
"script": "test",
@ -37,6 +37,6 @@
}
}
}
}
}<% } %>
]
}

View File

@ -28,6 +28,9 @@ describe('Workspace Schematic', () => {
const files = tree.files;
expect(files).toEqual(
jasmine.arrayContaining([
'/.vscode/extensions.json',
'/.vscode/launch.json',
'/.vscode/tasks.json',
'/.editorconfig',
'/angular.json',
'/.gitignore',
@ -66,6 +69,9 @@ describe('Workspace Schematic', () => {
const files = tree.files;
expect(files).toEqual(
jasmine.arrayContaining([
'/.vscode/extensions.json',
'/.vscode/launch.json',
'/.vscode/tasks.json',
'/angular.json',
'/.gitignore',
'/package.json',
@ -106,4 +112,24 @@ describe('Workspace Schematic', () => {
expect(compilerOptions.strict).toBe(true);
expect(angularCompilerOptions.strictTemplates).toBe(true);
});
it('should add vscode testing configuration', async () => {
const tree = await schematicRunner
.runSchematicAsync('workspace', { ...defaultOptions })
.toPromise();
const { configurations } = parseJson(tree.readContent('.vscode/launch.json').toString());
expect(configurations).toContain(jasmine.objectContaining({ name: 'ng test' }));
const { tasks } = parseJson(tree.readContent('.vscode/tasks.json').toString());
expect(tasks).toContain(jasmine.objectContaining({ type: 'npm', script: 'test' }));
});
it('should not add vscode testing configuration when using minimal', async () => {
const tree = await schematicRunner
.runSchematicAsync('workspace', { ...defaultOptions, minimal: true })
.toPromise();
const { configurations } = parseJson(tree.readContent('.vscode/launch.json').toString());
expect(configurations).not.toContain(jasmine.objectContaining({ name: 'ng test' }));
const { tasks } = parseJson(tree.readContent('.vscode/tasks.json').toString());
expect(tasks).not.toContain(jasmine.objectContaining({ type: 'npm', script: 'test' }));
});
});