From 97e161f5e94edcb11209e54d1e0b7a164b8ace94 Mon Sep 17 00:00:00 2001 From: Alan Agius <17563226+alan-agius4@users.noreply.github.com> Date: Tue, 8 Jul 2025 08:08:30 +0000 Subject: [PATCH 1/5] build: change size to "medium" and "small" There are several warnings about tests whose specified size is too big. These tests shards run under 300s and thus `medium` is more appropiate. --- .../testing/builder/src/builder-harness.ts | 3 +- packages/angular/build/BUILD.bazel | 12 +-- .../tests/options/polyfills_spec.ts | 100 +++++++++--------- 3 files changed, 59 insertions(+), 56 deletions(-) diff --git a/modules/testing/builder/src/builder-harness.ts b/modules/testing/builder/src/builder-harness.ts index 092206698f83..ec4973efa021 100644 --- a/modules/testing/builder/src/builder-harness.ts +++ b/modules/testing/builder/src/builder-harness.ts @@ -263,7 +263,7 @@ export class BuilderHarness { } const logs: logging.LogEntry[] = []; - context.logger.subscribe((e) => logs.push(e)); + const logger$ = context.logger.subscribe((e) => logs.push(e)); return observableFrom(this.schemaRegistry.compile(this.builderInfo.optionSchema)).pipe( mergeMap((validator) => validator(targetOptions)), @@ -302,6 +302,7 @@ export class BuilderHarness { }), finalize(() => { this.watcherNotifier = undefined; + logger$.unsubscribe(); for (const teardown of context.teardowns) { // eslint-disable-next-line @typescript-eslint/no-floating-promises diff --git a/packages/angular/build/BUILD.bazel b/packages/angular/build/BUILD.bazel index e46c2da6fcee..69d8ac3e2dd8 100644 --- a/packages/angular/build/BUILD.bazel +++ b/packages/angular/build/BUILD.bazel @@ -291,15 +291,15 @@ ts_project( jasmine_test( name = "application_integration_tests", - size = "large", + size = "medium", data = [":application_integration_test_lib"], flaky = True, - shard_count = 20, + shard_count = 25, ) jasmine_test( name = "dev-server_integration_tests", - size = "large", + size = "medium", data = [":dev-server_integration_test_lib"], flaky = True, shard_count = 10, @@ -307,7 +307,7 @@ jasmine_test( jasmine_test( name = "karma_integration_tests", - size = "large", + size = "medium", data = [":karma_integration_test_lib"], env = { # TODO: Replace Puppeteer downloaded browsers with Bazel-managed browsers, @@ -320,9 +320,9 @@ jasmine_test( jasmine_test( name = "unit-test_integration_tests", - size = "large", + size = "small", data = [":unit-test_integration_test_lib"], - shard_count = 10, + shard_count = 5, ) genrule( diff --git a/packages/angular/build/src/builders/application/tests/options/polyfills_spec.ts b/packages/angular/build/src/builders/application/tests/options/polyfills_spec.ts index 290ea281208d..bcbb21f237a7 100644 --- a/packages/angular/build/src/builders/application/tests/options/polyfills_spec.ts +++ b/packages/angular/build/src/builders/application/tests/options/polyfills_spec.ts @@ -16,71 +16,73 @@ const testsVariants: [suitName: string, baseUrl: string | undefined][] = [ ]; describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => { - for (const [suitName, baseUrl] of testsVariants) { - describe(suitName, () => { - beforeEach(async () => { - await harness.modifyFile('tsconfig.json', (content) => { - const tsconfig = JSON.parse(content); - tsconfig.compilerOptions.baseUrl = baseUrl; - - return JSON.stringify(tsconfig); - }); - }); - - it('uses a provided TypeScript file', async () => { - harness.useTarget('build', { - ...BASE_OPTIONS, - polyfills: ['src/polyfills.ts'], + describe('Option: polyfills', () => { + for (const [suitName, baseUrl] of testsVariants) { + describe(suitName, () => { + beforeEach(async () => { + await harness.modifyFile('tsconfig.json', (content) => { + const tsconfig = JSON.parse(content); + tsconfig.compilerOptions.baseUrl = baseUrl; + + return JSON.stringify(tsconfig); + }); }); - const { result } = await harness.executeOnce(); + it('uses a provided TypeScript file', async () => { + harness.useTarget('build', { + ...BASE_OPTIONS, + polyfills: ['src/polyfills.ts'], + }); - expect(result?.success).toBe(true); - - harness.expectFile('dist/browser/polyfills.js').toExist(); - }); + const { result } = await harness.executeOnce(); - it('uses a provided JavaScript file', async () => { - await harness.writeFile('src/polyfills.js', `console.log('main');`); + expect(result?.success).toBe(true); - harness.useTarget('build', { - ...BASE_OPTIONS, - polyfills: ['src/polyfills.js'], + harness.expectFile('dist/browser/polyfills.js').toExist(); }); - const { result } = await harness.executeOnce(); + it('uses a provided JavaScript file', async () => { + await harness.writeFile('src/polyfills.js', `console.log('main');`); - expect(result?.success).toBe(true); + harness.useTarget('build', { + ...BASE_OPTIONS, + polyfills: ['src/polyfills.js'], + }); - harness.expectFile('dist/browser/polyfills.js').content.toContain(`console.log("main")`); - }); + const { result } = await harness.executeOnce(); + + expect(result?.success).toBe(true); - it('fails and shows an error when file does not exist', async () => { - harness.useTarget('build', { - ...BASE_OPTIONS, - polyfills: ['src/missing.ts'], + harness.expectFile('dist/browser/polyfills.js').content.toContain(`console.log("main")`); }); - const { result, logs } = await harness.executeOnce({ outputLogsOnFailure: false }); + it('fails and shows an error when file does not exist', async () => { + harness.useTarget('build', { + ...BASE_OPTIONS, + polyfills: ['src/missing.ts'], + }); - expect(result?.success).toBe(false); - expect(logs).toContain( - jasmine.objectContaining({ message: jasmine.stringMatching('Could not resolve') }), - ); + const { result, logs } = await harness.executeOnce({ outputLogsOnFailure: false }); - harness.expectFile('dist/browser/polyfills.js').toNotExist(); - }); + expect(result?.success).toBe(false); + expect(logs).toContain( + jasmine.objectContaining({ message: jasmine.stringMatching('Could not resolve') }), + ); - it('resolves module specifiers in array', async () => { - harness.useTarget('build', { - ...BASE_OPTIONS, - polyfills: ['zone.js', 'zone.js/testing'], + harness.expectFile('dist/browser/polyfills.js').toNotExist(); }); - const { result } = await harness.executeOnce(); - expect(result?.success).toBeTrue(); - harness.expectFile('dist/browser/polyfills.js').toExist(); + it('resolves module specifiers in array', async () => { + harness.useTarget('build', { + ...BASE_OPTIONS, + polyfills: ['zone.js', 'zone.js/testing'], + }); + + const { result } = await harness.executeOnce(); + expect(result?.success).toBeTrue(); + harness.expectFile('dist/browser/polyfills.js').toExist(); + }); }); - }); - } + } + }); }); From d5a18a3ba0e30bd2b1a5f21be0644a4f9377304a Mon Sep 17 00:00:00 2001 From: Alan Agius <17563226+alan-agius4@users.noreply.github.com> Date: Tue, 8 Jul 2025 09:19:35 +0000 Subject: [PATCH 2/5] test: reduce karma test flakes by using `clearContext` that is set in the builder This is needed as a workaround for https://github.com/angular/angular-cli/issues/28271 --- .../testing/builder/projects/hello-world-app/karma.conf.js | 3 --- .../src/builders/application/tests/options/polyfills_spec.ts | 4 ++++ .../test/hello-world-lib/projects/lib/karma.conf.js | 3 --- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/modules/testing/builder/projects/hello-world-app/karma.conf.js b/modules/testing/builder/projects/hello-world-app/karma.conf.js index 1cf153a1da81..7d5f7c8d98f5 100644 --- a/modules/testing/builder/projects/hello-world-app/karma.conf.js +++ b/modules/testing/builder/projects/hello-world-app/karma.conf.js @@ -23,9 +23,6 @@ module.exports = function(config) { require('karma-coverage'), require('@angular-devkit/build-angular/plugins/karma'), ], - client: { - clearContext: false, // leave Jasmine Spec Runner output visible in browser - }, jasmineHtmlReporter: { suppressAll: true // removes the duplicated traces }, diff --git a/packages/angular/build/src/builders/application/tests/options/polyfills_spec.ts b/packages/angular/build/src/builders/application/tests/options/polyfills_spec.ts index bcbb21f237a7..fcf6a1e39c9e 100644 --- a/packages/angular/build/src/builders/application/tests/options/polyfills_spec.ts +++ b/packages/angular/build/src/builders/application/tests/options/polyfills_spec.ts @@ -20,6 +20,10 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => { for (const [suitName, baseUrl] of testsVariants) { describe(suitName, () => { beforeEach(async () => { + beforeEach(async () => { + await harness.writeFile('src/main.ts', 'console.log("TEST");'); + }); + await harness.modifyFile('tsconfig.json', (content) => { const tsconfig = JSON.parse(content); tsconfig.compilerOptions.baseUrl = baseUrl; diff --git a/packages/angular_devkit/build_angular/test/hello-world-lib/projects/lib/karma.conf.js b/packages/angular_devkit/build_angular/test/hello-world-lib/projects/lib/karma.conf.js index fe024ed63ee2..5573d103b26e 100644 --- a/packages/angular_devkit/build_angular/test/hello-world-lib/projects/lib/karma.conf.js +++ b/packages/angular_devkit/build_angular/test/hello-world-lib/projects/lib/karma.conf.js @@ -20,9 +20,6 @@ module.exports = function (config) { require('karma-coverage-istanbul-reporter'), require('@angular-devkit/build-angular/plugins/karma') ], - client: { - clearContext: false // leave Jasmine Spec Runner output visible in browser - }, jasmineHtmlReporter: { suppressAll: true // removes the duplicated traces }, From ef327194ec8a3d6a3ff56f70fce9a6fd005d1086 Mon Sep 17 00:00:00 2001 From: Alan Agius <17563226+alan-agius4@users.noreply.github.com> Date: Tue, 8 Jul 2025 09:28:06 +0000 Subject: [PATCH 3/5] test: remove contents of `main.ts` from polyfill tests These test do not need the contents of the `main.ts` --- .../src/builders/application/tests/options/polyfills_spec.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/angular/build/src/builders/application/tests/options/polyfills_spec.ts b/packages/angular/build/src/builders/application/tests/options/polyfills_spec.ts index fcf6a1e39c9e..8b5cc3a09ab3 100644 --- a/packages/angular/build/src/builders/application/tests/options/polyfills_spec.ts +++ b/packages/angular/build/src/builders/application/tests/options/polyfills_spec.ts @@ -20,9 +20,7 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => { for (const [suitName, baseUrl] of testsVariants) { describe(suitName, () => { beforeEach(async () => { - beforeEach(async () => { - await harness.writeFile('src/main.ts', 'console.log("TEST");'); - }); + await harness.writeFile('src/main.ts', 'console.log("TEST");'); await harness.modifyFile('tsconfig.json', (content) => { const tsconfig = JSON.parse(content); From 1ca3656bf5be87022cdcc3bd0381329f6f6a5217 Mon Sep 17 00:00:00 2001 From: Alan Agius <17563226+alan-agius4@users.noreply.github.com> Date: Tue, 8 Jul 2025 12:28:11 +0000 Subject: [PATCH 4/5] test: Reduce default timeouts The default 2.5-minute timeout is often unnecessary and can interfere with test execution. Specifically, Bazel may terminate the test before Jasmine does, making it harder to identify which test is causing the issue. --- modules/testing/builder/src/test-utils.ts | 4 +- .../tests/options/output-path_spec.ts | 40 +++++++++---------- .../src/builders/app-shell/app-shell_spec.ts | 9 +++++ .../src/builders/ng-packagr/works_spec.ts | 13 ++++-- .../src/builders/prerender/works_spec.ts | 10 +++++ 5 files changed, 51 insertions(+), 25 deletions(-) diff --git a/modules/testing/builder/src/test-utils.ts b/modules/testing/builder/src/test-utils.ts index 126af073b726..f41cb42d1ea6 100644 --- a/modules/testing/builder/src/test-utils.ts +++ b/modules/testing/builder/src/test-utils.ts @@ -24,8 +24,8 @@ import { import path from 'node:path'; import { firstValueFrom } from 'rxjs'; -// Default timeout for large specs is 2.5 minutes. -jasmine.DEFAULT_TIMEOUT_INTERVAL = 150000; +// Default timeout for large specs is 60s. +jasmine.DEFAULT_TIMEOUT_INTERVAL = 60_000; export const workspaceRoot = join(normalize(__dirname), `../projects/hello-world-app/`); export const host = new TestProjectHost(workspaceRoot); diff --git a/packages/angular/build/src/builders/application/tests/options/output-path_spec.ts b/packages/angular/build/src/builders/application/tests/options/output-path_spec.ts index f8d4513c7de7..3f4898e1c6d8 100644 --- a/packages/angular/build/src/builders/application/tests/options/output-path_spec.ts +++ b/packages/angular/build/src/builders/application/tests/options/output-path_spec.ts @@ -10,28 +10,28 @@ import { buildApplication } from '../../index'; import { APPLICATION_BUILDER_INFO, BASE_OPTIONS, describeBuilder } from '../setup'; describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => { - beforeEach(async () => { - // Add a global stylesheet media file - await harness.writeFile('src/styles.css', `h1 { background: url('./spectrum.png')}`); - // Add a component stylesheet media file - await harness.writeFile('src/app/abc.svg', ''); - await harness.writeFile('src/app/app.component.css', `h2 { background: url('./abc.svg')}`); - - // Enable SSR - await harness.modifyFile('src/tsconfig.app.json', (content) => { - const tsConfig = JSON.parse(content); - tsConfig.files ??= []; - tsConfig.files.push('main.server.ts', 'server.ts'); - - return JSON.stringify(tsConfig); - }); + describe('Option: "outputPath"', () => { + beforeEach(async () => { + // Add a global stylesheet media file + await harness.writeFile('src/styles.css', `h1 { background: url('./spectrum.png')}`); + // Add a component stylesheet media file + await harness.writeFile('src/app/abc.svg', ''); + await harness.writeFile('src/app/app.component.css', `h2 { background: url('./abc.svg')}`); + + // Enable SSR + await harness.modifyFile('src/tsconfig.app.json', (content) => { + const tsConfig = JSON.parse(content); + tsConfig.files ??= []; + tsConfig.files.push('main.server.ts', 'server.ts'); + + return JSON.stringify(tsConfig); + }); - // Application server code is not needed in this test - await harness.writeFile('src/main.server.ts', `console.log('Hello!');`); - await harness.writeFile('src/server.ts', `console.log('Hello!');`); - }); + // Application server code is not needed in this test + await harness.writeFile('src/main.server.ts', `console.log('Hello!');`); + await harness.writeFile('src/server.ts', `console.log('Hello!');`); + }); - describe('Option: "outputPath"', () => { describe(`when option value is is a string`, () => { beforeEach(() => { harness.useTarget('build', { diff --git a/packages/angular_devkit/build_angular/src/builders/app-shell/app-shell_spec.ts b/packages/angular_devkit/build_angular/src/builders/app-shell/app-shell_spec.ts index 468bdb6ff2bd..6ee544305b06 100644 --- a/packages/angular_devkit/build_angular/src/builders/app-shell/app-shell_spec.ts +++ b/packages/angular_devkit/build_angular/src/builders/app-shell/app-shell_spec.ts @@ -13,6 +13,15 @@ import { createArchitect, host } from '../../testing/test-utils'; describe('AppShell Builder', () => { const target = { project: 'app', target: 'app-shell' }; let architect: Architect; + const originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; + + beforeAll(() => { + jasmine.DEFAULT_TIMEOUT_INTERVAL = 100_000; + }); + + afterAll(() => { + jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; + }); beforeEach(async () => { await host.initialize().toPromise(); diff --git a/packages/angular_devkit/build_angular/src/builders/ng-packagr/works_spec.ts b/packages/angular_devkit/build_angular/src/builders/ng-packagr/works_spec.ts index 06609780b8b8..4bf1ac2dec91 100644 --- a/packages/angular_devkit/build_angular/src/builders/ng-packagr/works_spec.ts +++ b/packages/angular_devkit/build_angular/src/builders/ng-packagr/works_spec.ts @@ -19,14 +19,21 @@ import { } from '@angular-devkit/core'; import { debounceTime, map, take, tap } from 'rxjs'; -// Default timeout for large specs is 2.5 minutes. -jasmine.DEFAULT_TIMEOUT_INTERVAL = 150000; - describe('NgPackagr Builder', () => { const workspaceRoot = join(normalize(__dirname), `../../../test/hello-world-lib/`); const host = new TestProjectHost(workspaceRoot); let architect: Architect; + const originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; + + beforeAll(() => { + jasmine.DEFAULT_TIMEOUT_INTERVAL = 80_000; + }); + + afterAll(() => { + jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; + }); + beforeEach(async () => { await host.initialize().toPromise(); diff --git a/packages/angular_devkit/build_angular/src/builders/prerender/works_spec.ts b/packages/angular_devkit/build_angular/src/builders/prerender/works_spec.ts index 4d26c6049542..8c55c923d02d 100644 --- a/packages/angular_devkit/build_angular/src/builders/prerender/works_spec.ts +++ b/packages/angular_devkit/build_angular/src/builders/prerender/works_spec.ts @@ -11,6 +11,16 @@ import { join, normalize, virtualFs } from '@angular-devkit/core'; import { createArchitect, host } from '../../testing/test-utils'; describe('Prerender Builder', () => { + const originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; + + beforeAll(() => { + jasmine.DEFAULT_TIMEOUT_INTERVAL = 100_000; + }); + + afterAll(() => { + jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; + }); + const target = { project: 'app', target: 'prerender' }; let architect: Architect; From 2f6495b0f5effa44308154038ce2dfb75f5e8183 Mon Sep 17 00:00:00 2001 From: Alan Agius <17563226+alan-agius4@users.noreply.github.com> Date: Tue, 8 Jul 2025 12:55:29 +0000 Subject: [PATCH 5/5] refactor: reduce the number of builds done in output-path_spec Significantly reduces the number of application builds performed in this test --- .../tests/options/output-path_spec.ts | 129 ++---------------- 1 file changed, 13 insertions(+), 116 deletions(-) diff --git a/packages/angular/build/src/builders/application/tests/options/output-path_spec.ts b/packages/angular/build/src/builders/application/tests/options/output-path_spec.ts index 3f4898e1c6d8..b6c72b9bee58 100644 --- a/packages/angular/build/src/builders/application/tests/options/output-path_spec.ts +++ b/packages/angular/build/src/builders/application/tests/options/output-path_spec.ts @@ -32,8 +32,8 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => { await harness.writeFile('src/server.ts', `console.log('Hello!');`); }); - describe(`when option value is is a string`, () => { - beforeEach(() => { + describe('when option value is a string', () => { + it('should emit browser, media and server files in their respective directories', async () => { harness.useTarget('build', { ...BASE_OPTIONS, polyfills: [], @@ -44,34 +44,20 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => { entry: 'src/server.ts', }, }); - }); - it(`should emit browser bundles in 'browser' directory`, async () => { const { result } = await harness.executeOnce(); expect(result?.success).toBeTrue(); harness.expectFile('dist/browser/main.js').toExist(); - }); - - it(`should emit media files in 'browser/media' directory`, async () => { - const { result } = await harness.executeOnce(); - expect(result?.success).toBeTrue(); - harness.expectFile('dist/browser/media/spectrum.png').toExist(); harness.expectFile('dist/browser/media/abc.svg').toExist(); - }); - - it(`should emit server bundles in 'server' directory`, async () => { - const { result } = await harness.executeOnce(); - expect(result?.success).toBeTrue(); - harness.expectFile('dist/server/server.mjs').toExist(); }); }); - describe(`when option value is an object`, () => { + describe('when option value is an object', () => { describe(`'media' is set to 'resources'`, () => { - beforeEach(() => { + it('should emit browser, media and server files in their respective directories', async () => { harness.useTarget('build', { ...BASE_OPTIONS, polyfills: [], @@ -85,33 +71,19 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => { entry: 'src/server.ts', }, }); - }); - it(`should emit browser bundles in 'browser' directory`, async () => { const { result } = await harness.executeOnce(); expect(result?.success).toBeTrue(); harness.expectFile('dist/browser/main.js').toExist(); - }); - - it(`should emit media files in 'browser/resource' directory`, async () => { - const { result } = await harness.executeOnce(); - expect(result?.success).toBeTrue(); - harness.expectFile('dist/browser/resource/spectrum.png').toExist(); harness.expectFile('dist/browser/resource/abc.svg').toExist(); - }); - - it(`should emit server bundles in 'server' directory`, async () => { - const { result } = await harness.executeOnce(); - expect(result?.success).toBeTrue(); - harness.expectFile('dist/server/server.mjs').toExist(); }); }); describe(`'media' is set to ''`, () => { - beforeEach(() => { + it('should emit browser, media and server files in their respective directories', async () => { harness.useTarget('build', { ...BASE_OPTIONS, polyfills: [], @@ -125,36 +97,20 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => { entry: 'src/server.ts', }, }); - }); - it(`should emit browser bundles in 'browser' directory`, async () => { const { result } = await harness.executeOnce(); expect(result?.success).toBeTrue(); harness.expectFile('dist/browser/main.js').toExist(); - }); - - it(`should emit media files in 'browser' directory`, async () => { - const { result } = await harness.executeOnce(); - expect(result?.success).toBeTrue(); - harness.expectFile('dist/browser/spectrum.png').toExist(); harness.expectFile('dist/browser/abc.svg').toExist(); - - // Component CSS should not be considered media - harness.expectFile('dist/browser/app.component.css').toNotExist(); - }); - - it(`should emit server bundles in 'server' directory`, async () => { - const { result } = await harness.executeOnce(); - expect(result?.success).toBeTrue(); - harness.expectFile('dist/server/server.mjs').toExist(); + harness.expectFile('dist/browser/app.component.css').toNotExist(); }); }); describe(`'server' is set to 'node-server'`, () => { - beforeEach(() => { + it('should emit browser, media and server files in their respective directories', async () => { harness.useTarget('build', { ...BASE_OPTIONS, polyfills: [], @@ -168,33 +124,19 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => { entry: 'src/server.ts', }, }); - }); - it(`should emit browser bundles in 'browser' directory`, async () => { const { result } = await harness.executeOnce(); expect(result?.success).toBeTrue(); harness.expectFile('dist/browser/main.js').toExist(); - }); - - it(`should emit media files in 'browser/media' directory`, async () => { - const { result } = await harness.executeOnce(); - expect(result?.success).toBeTrue(); - harness.expectFile('dist/browser/media/spectrum.png').toExist(); harness.expectFile('dist/browser/media/abc.svg').toExist(); - }); - - it(`should emit server bundles in 'node-server' directory`, async () => { - const { result } = await harness.executeOnce(); - expect(result?.success).toBeTrue(); - harness.expectFile('dist/node-server/server.mjs').toExist(); }); }); describe(`'browser' is set to 'public'`, () => { - beforeEach(() => { + it('should emit browser, media and server files in their respective directories', async () => { harness.useTarget('build', { ...BASE_OPTIONS, polyfills: [], @@ -208,51 +150,19 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => { entry: 'src/server.ts', }, }); - }); - it(`should emit browser bundles in 'public' directory`, async () => { const { result } = await harness.executeOnce(); expect(result?.success).toBeTrue(); harness.expectFile('dist/public/main.js').toExist(); - }); - - it(`should emit media files in 'public/media' directory`, async () => { - const { result } = await harness.executeOnce(); - expect(result?.success).toBeTrue(); - harness.expectFile('dist/public/media/spectrum.png').toExist(); harness.expectFile('dist/public/media/abc.svg').toExist(); - }); - - it(`should emit server bundles in 'server' directory`, async () => { - const { result } = await harness.executeOnce(); - expect(result?.success).toBeTrue(); - harness.expectFile('dist/server/server.mjs').toExist(); }); }); describe(`'browser' is set to ''`, () => { - it(`should emit browser bundles in '' directory`, async () => { - harness.useTarget('build', { - ...BASE_OPTIONS, - polyfills: [], - server: 'src/main.server.ts', - outputPath: { - base: 'dist', - browser: '', - }, - ssr: false, - }); - - const { result } = await harness.executeOnce(); - expect(result?.success).toBeTrue(); - - harness.expectFile('dist/main.js').toExist(); - }); - - it(`should emit media files in 'media' directory`, async () => { + it('should emit browser and media files in the root output directory when ssr is disabled', async () => { harness.useTarget('build', { ...BASE_OPTIONS, polyfills: [], @@ -268,11 +178,12 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => { const { result } = await harness.executeOnce(); expect(result?.success).toBeTrue(); + harness.expectFile('dist/main.js').toExist(); harness.expectFile('dist/media/spectrum.png').toExist(); harness.expectFile('dist/media/abc.svg').toExist(); }); - it(`should error when ssr is enabled`, async () => { + it('should error when ssr is enabled', async () => { harness.useTarget('build', { ...BASE_OPTIONS, polyfills: [], @@ -298,8 +209,8 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => { }); }); - describe(`'server' is set ''`, () => { - beforeEach(() => { + describe(`'server' is set to ''`, () => { + it('should emit browser, media and server files in their respective directories', async () => { harness.useTarget('build', { ...BASE_OPTIONS, polyfills: [], @@ -313,27 +224,13 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => { entry: 'src/server.ts', }, }); - }); - it(`should emit browser bundles in 'browser' directory`, async () => { const { result } = await harness.executeOnce(); expect(result?.success).toBeTrue(); harness.expectFile('dist/browser/main.js').toExist(); - }); - - it(`should emit media files in 'browser/media' directory`, async () => { - const { result } = await harness.executeOnce(); - expect(result?.success).toBeTrue(); - harness.expectFile('dist/browser/media/spectrum.png').toExist(); harness.expectFile('dist/browser/media/abc.svg').toExist(); - }); - - it(`should emit server bundles in '' directory`, async () => { - const { result } = await harness.executeOnce(); - expect(result?.success).toBeTrue(); - harness.expectFile('dist/server.mjs').toExist(); }); });