hunk.code_window:   build,
     context,
   } from 'esbuild';
   import { basename, extname, relative } from 'node:path';
   export type BundleContextResult =
     | { errors: Message[]; warnings: Message[] }
     | {
         errors: undefined;
  
hunk.labels: keep keep keep replace keep keep keep keep keep
hunk.after_edit: import { basename, extname, join, relative } from 'node:path';
  
hunk.file_path: packages/angular_devkit/build_angular/src/tools/esbuild/bundler-context.ts
hunk.type: replace
file: import { writeFile } from '../../utils/fs';
  import { ng } from '../../utils/process';
  
  export default async function () {
    await writeFile(
      'src/app/app.component.spec.ts',
      `
        it('show fail', () => {
          expect(undefined).toBeTruthy();
        });
      `,
    );
  
    // when sourcemaps are 'on' the stacktrace will point to the spec.ts file.
    try {
      await ng('test', '--no-watch', '--source-map');
      throw new Error('ng test should have failed.');
    } catch (error) {
      if (!(error instanceof Error && error.message.includes('app.component.spec.ts'))) {
        throw error;
      }
    }
  
    // when sourcemaps are 'off' the stacktrace won't point to the spec.ts file.
    try {
      await ng('test', '--no-watch', '--no-source-map');
      throw new Error('ng test should have failed.');
    } catch (error) {
      if (!(error instanceof Error && error.message.includes('main.js'))) {
        throw error;
      }
    }
  }
  