File tree Expand file tree Collapse file tree 2 files changed +14
-14
lines changed
packages/angular/build/src/builders/unit-test Expand file tree Collapse file tree 2 files changed +14
-14
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import { normalizeCacheOptions } from '../../utils/normalize-cache';
1313import { getProjectRootPaths } from '../../utils/project-metadata' ;
1414import { isTTY } from '../../utils/tty' ;
1515import type { Schema as UnitTestBuilderOptions } from './schema' ;
16+ import { toPosixPath } from '../../utils/path' ;
1617
1718export type NormalizedUnitTestBuilderOptions = Awaited < ReturnType < typeof normalizeOptions > > ;
1819
@@ -92,8 +93,8 @@ export async function normalizeOptions(
9293 cacheOptions,
9394 // Target/configuration specified options
9495 buildTarget,
95- include : options . include ?? [ '**/*.spec.ts' ] ,
96- exclude : options . exclude ,
96+ include : options . include ?. map ( toPosixPath ) ?? [ '**/*.spec.ts' ] ,
97+ exclude : options . exclude ?. map ( toPosixPath ) ,
9798 filter,
9899 runnerName : runner ?? 'vitest' ,
99100 coverage : {
Original file line number Diff line number Diff line change @@ -171,28 +171,27 @@ export function createVitestPlugins(pluginOptions: PluginOptions): VitestPlugins
171171 name : 'angular:test-in-memory-provider' ,
172172 enforce : 'pre' ,
173173 resolveId : ( id , importer ) => {
174- if ( importer && ( id [ 0 ] === '.' || id [ 0 ] === '/' ) ) {
175- let fullPath ;
176- if ( testFileToEntryPoint . has ( importer ) ) {
177- fullPath = toPosixPath ( path . join ( workspaceRoot , id ) ) ;
178- } else {
179- fullPath = toPosixPath ( path . join ( path . dirname ( importer ) , id ) ) ;
180- }
181-
174+ const idPosix = toPosixPath ( id ) ;
175+ if ( importer && ( idPosix [ 0 ] === '.' || idPosix [ 0 ] === '/' ) ) {
176+ const directory = testFileToEntryPoint . has ( importer )
177+ ? workspaceRoot
178+ : path . dirname ( importer ) ;
179+ const fullPath = toPosixPath ( path . join ( directory , idPosix ) ) ;
182180 const relativePath = path . relative ( workspaceRoot , fullPath ) ;
181+
183182 if ( buildResultFiles . has ( toPosixPath ( relativePath ) ) ) {
184183 return fullPath ;
185184 }
186185 }
187186
188- if ( testFileToEntryPoint . has ( id ) ) {
189- return id ;
187+ if ( testFileToEntryPoint . has ( idPosix ) ) {
188+ return idPosix ;
190189 }
191190
192191 assert ( buildResultFiles . size > 0 , 'buildResult must be available for resolving.' ) ;
193- const relativePath = path . relative ( workspaceRoot , id ) ;
192+ const relativePath = path . relative ( workspaceRoot , idPosix ) ;
194193 if ( buildResultFiles . has ( toPosixPath ( relativePath ) ) ) {
195- return id ;
194+ return idPosix ;
196195 }
197196 } ,
198197 load : async ( id ) => {
You can’t perform that action at this time.
0 commit comments