@@ -130,6 +130,103 @@ describe(`Migration to use the application builder`, () => {
|
130 | 130 | expect(builderMode).toBeUndefined();
|
131 | 131 | });
|
132 | 132 |
|
| 133 | +it(`should update file for 'karmaConfig' karma option (no require trailing comma)`, async () => { |
| 134 | +addWorkspaceTarget(tree, 'test', { |
| 135 | +'builder': Builders.Karma, |
| 136 | +'options': { |
| 137 | +'karmaConfig': './karma.conf.js', |
| 138 | +'polyfills': ['zone.js', 'zone.js/testing'], |
| 139 | +'tsConfig': 'projects/app-a/tsconfig.spec.json', |
| 140 | +}, |
| 141 | +}); |
| 142 | +tree.create( |
| 143 | +'./karma.conf.js', |
| 144 | +` |
| 145 | +module.exports = function (config) { |
| 146 | +config.set({ |
| 147 | +basePath: '', |
| 148 | +frameworks: ['jasmine', '@angular-devkit/build-angular'], |
| 149 | +plugins: [ |
| 150 | +require('karma-jasmine'), |
| 151 | +require('karma-chrome-launcher'), |
| 152 | +require('karma-jasmine-html-reporter'), |
| 153 | +require('karma-coverage'), |
| 154 | +require('@angular-devkit/build-angular/plugins/karma') |
| 155 | +] |
| 156 | +}); |
| 157 | +};`, |
| 158 | +); |
| 159 | + |
| 160 | +const newTree = await schematicRunner.runSchematic(schematicName, {}, tree); |
| 161 | +const { |
| 162 | +projects: { app }, |
| 163 | +} = JSON.parse(newTree.readContent('/angular.json')); |
| 164 | + |
| 165 | +const { karmaConfig } = app.architect['test'].options; |
| 166 | +expect(karmaConfig).toBe('./karma.conf.js'); |
| 167 | + |
| 168 | +const karmaConfigText = newTree.readText('./karma.conf.js'); |
| 169 | +expect(karmaConfigText).not.toContain(`require('@angular-devkit/build-angular/plugins/karma')`); |
| 170 | +}); |
| 171 | + |
| 172 | +it(`should update file for 'karmaConfig' karma option (require trailing comma)`, async () => { |
| 173 | +addWorkspaceTarget(tree, 'test', { |
| 174 | +'builder': Builders.Karma, |
| 175 | +'options': { |
| 176 | +'karmaConfig': './karma.conf.js', |
| 177 | +'polyfills': ['zone.js', 'zone.js/testing'], |
| 178 | +'tsConfig': 'projects/app-a/tsconfig.spec.json', |
| 179 | +}, |
| 180 | +}); |
| 181 | +tree.create( |
| 182 | +'./karma.conf.js', |
| 183 | +` |
| 184 | +module.exports = function (config) { |
| 185 | +config.set({ |
| 186 | +basePath: '', |
| 187 | +frameworks: ['jasmine', '@angular-devkit/build-angular'], |
| 188 | +plugins: [ |
| 189 | +require('karma-jasmine'), |
| 190 | +require('karma-chrome-launcher'), |
| 191 | +require('karma-jasmine-html-reporter'), |
| 192 | +require('karma-coverage'), |
| 193 | +require('@angular-devkit/build-angular/plugins/karma'), |
| 194 | +] |
| 195 | +}); |
| 196 | +};`, |
| 197 | +); |
| 198 | + |
| 199 | +const newTree = await schematicRunner.runSchematic(schematicName, {}, tree); |
| 200 | +const { |
| 201 | +projects: { app }, |
| 202 | +} = JSON.parse(newTree.readContent('/angular.json')); |
| 203 | + |
| 204 | +const { karmaConfig } = app.architect['test'].options; |
| 205 | +expect(karmaConfig).toBe('./karma.conf.js'); |
| 206 | + |
| 207 | +const karmaConfigText = newTree.readText('./karma.conf.js'); |
| 208 | +expect(karmaConfigText).not.toContain(`require('@angular-devkit/build-angular/plugins/karma')`); |
| 209 | +}); |
| 210 | + |
| 211 | +it(`should ignore missing file for 'karmaConfig' karma option`, async () => { |
| 212 | +addWorkspaceTarget(tree, 'test', { |
| 213 | +'builder': Builders.Karma, |
| 214 | +'options': { |
| 215 | +'karmaConfig': './karma.conf.js', |
| 216 | +'polyfills': ['zone.js', 'zone.js/testing'], |
| 217 | +'tsConfig': 'projects/app-a/tsconfig.spec.json', |
| 218 | +}, |
| 219 | +}); |
| 220 | + |
| 221 | +const newTree = await schematicRunner.runSchematic(schematicName, {}, tree); |
| 222 | +const { |
| 223 | +projects: { app }, |
| 224 | +} = JSON.parse(newTree.readContent('/angular.json')); |
| 225 | + |
| 226 | +const { karmaConfig } = app.architect['test'].options; |
| 227 | +expect(karmaConfig).toBe('./karma.conf.js'); |
| 228 | +}); |
| 229 | + |
133 | 230 | it('should remove tilde prefix from CSS @import specifiers', async () => {
|
134 | 231 | // Replace outputPath
|
135 | 232 | tree.create(
|
|
0 commit comments