Skip to content

Commit ab75868

Browse files
committed
fix: remove tests
1 parent dfc1171 commit ab75868

File tree

2 files changed

+22
-134
lines changed

2 files changed

+22
-134
lines changed

packages/plugin-coverage/src/lib/nx/coverage-paths.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ import type { CoverageResult } from '../config.js';
1818
* @param verbose optional verbose logging
1919
* @returns An array of coverage result information for the coverage plugin.
2020
*/
21-
export async function getNxCoveragePaths(
22-
targets: string[] = ['test'],
23-
projects?: string[],
24-
verbose?: boolean,
25-
): Promise<CoverageResult[]> {
21+
export async function getNxCoveragePaths(options: {
22+
targets?: string[];
23+
projects?: string[];
24+
verbose?: boolean;
25+
}): Promise<CoverageResult[]> {
26+
const { targets = ['test'], verbose, projects } = options;
2627
if (verbose) {
2728
ui().logger.info(
2829
bold('💡 Gathering coverage from the following nx projects:'),
@@ -192,13 +193,7 @@ export async function getCoveragePathForJest(
192193
}
193194

194195
if (path.isAbsolute(coverageDirectory)) {
195-
return {
196-
pathToProject: project.root,
197-
resultsPath: path.join(coverageDirectory, 'lcov.info'),
198-
};
196+
return path.join(coverageDirectory, 'lcov.info');
199197
}
200-
return {
201-
pathToProject: project.root,
202-
resultsPath: path.join(project.root, coverageDirectory, 'lcov.info'),
203-
};
198+
return path.join(project.root, coverageDirectory, 'lcov.info');
204199
}

packages/plugin-coverage/src/lib/nx/coverage-paths.unit.test.ts

Lines changed: 14 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,9 @@ describe('getCoveragePathForTarget', () => {
135135
},
136136
'test',
137137
),
138-
).resolves.toStrictEqual({
139-
pathToProject: path.join('packages', 'core'),
140-
resultsPath: path.join(
141-
'packages',
142-
'core',
143-
'coverage',
144-
'core',
145-
'lcov.info',
146-
),
147-
});
138+
).resolves.toBe(
139+
path.join('packages', 'core', 'coverage', 'core', 'lcov.info'),
140+
);
148141
});
149142

150143
it('should throw for unsupported executor (only vitest and jest are supported)', async () => {
@@ -284,16 +277,9 @@ describe('getCoveragePathForJest', () => {
284277
{ name: 'cli', root: path.join('packages', 'cli') },
285278
'unit-test',
286279
),
287-
).resolves.toEqual({
288-
pathToProject: path.join('packages', 'cli'),
289-
resultsPath: path.join(
290-
'packages',
291-
'cli',
292-
'coverage',
293-
'core',
294-
'lcov.info',
295-
),
296-
} satisfies CoverageResult);
280+
).resolves.toBe(
281+
path.join('packages', 'cli', 'coverage', 'core', 'lcov.info'),
282+
);
297283
});
298284

299285
it('should throw when coverageDirectory is not set in Jest config', async () => {
@@ -325,16 +311,9 @@ describe('getCoveragePathForJest', () => {
325311
{ name: 'cli', root: path.join('packages', 'cli') },
326312
'unit-test',
327313
),
328-
).resolves.toEqual({
329-
pathToProject: path.join('packages', 'cli'),
330-
resultsPath: path.join(
331-
'dist',
332-
'packages',
333-
'cli',
334-
'coverage',
335-
'lcov.info',
336-
),
337-
} satisfies CoverageResult);
314+
).resolves.toBe(
315+
path.join('dist', 'packages', 'cli', 'coverage', 'lcov.info'),
316+
);
338317
});
339318

340319
it('should throw when Jest config does not include lcov reporter', async () => {
@@ -357,12 +336,7 @@ describe('getCoveragePathForJest', () => {
357336
{ name: 'core', root: path.join('packages', 'core') },
358337
'integration-test',
359338
),
360-
).resolves.toEqual(
361-
expect.objectContaining({
362-
pathToProject: expect.any(String),
363-
resultsPath: expect.any(String),
364-
}),
365-
);
339+
).resolves.toBeTypeOf('string');
366340
});
367341

368342
it('should throw if lcov reporter from jest config overridden in project.json', async () => {
@@ -388,12 +362,7 @@ describe('getCoveragePathForJest', () => {
388362
{ name: 'core', root: path.join('packages', 'core') },
389363
'integration-test',
390364
),
391-
).resolves.toEqual(
392-
expect.objectContaining({
393-
pathToProject: expect.any(String),
394-
resultsPath: expect.any(String),
395-
}),
396-
);
365+
).resolves.toBeTypeOf('string');
397366
});
398367

399368
it('should not throw regarding missing lcov reporter if jest config uses preset', async () => {
@@ -403,12 +372,7 @@ describe('getCoveragePathForJest', () => {
403372
{ name: 'core', root: path.join('packages', 'core') },
404373
'test',
405374
),
406-
).resolves.toEqual(
407-
expect.objectContaining({
408-
pathToProject: expect.any(String),
409-
resultsPath: expect.any(String),
410-
}),
411-
);
375+
).resolves.toBeTypeOf('string');
412376
});
413377

414378
it('should handle absolute path in coverageDirectory', async () => {
@@ -426,79 +390,8 @@ describe('getCoveragePathForJest', () => {
426390
{ name: 'cli', root: path.join('packages', 'cli') },
427391
'unit-test',
428392
),
429-
).resolves.toEqual({
430-
pathToProject: path.join('packages', 'cli'),
431-
resultsPath: path.join(
432-
process.cwd(),
433-
'coverage',
434-
'packages',
435-
'cli',
436-
'lcov.info',
437-
),
438-
} satisfies CoverageResult);
439-
});
440-
});
441-
442-
describe('getNxCoveragePaths', () => {
443-
beforeEach(() => {
444-
vol.fromJSON(
445-
{
446-
'vitest-cli.config.ts': '',
447-
'vitest-core.config.ts': '',
448-
},
449-
MEMFS_VOLUME,
393+
).resolves.toBe(
394+
path.join(process.cwd(), 'coverage', 'packages', 'cli', 'lcov.info'),
450395
);
451-
452-
// Mock createProjectGraphAsync to return a mock project graph
453-
vi.doMock('@nx/devkit', () => ({
454-
createProjectGraphAsync: vi.fn().mockResolvedValue({
455-
nodes: {
456-
cli: {
457-
name: 'cli',
458-
type: 'lib',
459-
data: {
460-
name: 'cli',
461-
root: path.join('packages', 'cli'),
462-
targets: {
463-
'unit-test': {
464-
executor: '@nx/vite:test',
465-
options: {
466-
configFile: 'vitest-cli.config.ts',
467-
} satisfies VitestExecutorOptions,
468-
},
469-
},
470-
},
471-
},
472-
core: {
473-
name: 'core',
474-
type: 'lib',
475-
data: {
476-
name: 'core',
477-
root: path.join('packages', 'core'),
478-
targets: {
479-
'unit-test': {
480-
executor: '@nx/vite:test',
481-
options: {
482-
configFile: 'vitest-core.config.ts',
483-
} satisfies VitestExecutorOptions,
484-
},
485-
},
486-
},
487-
},
488-
},
489-
}),
490-
}));
491-
});
492-
493-
afterEach(() => {
494-
vi.doUnmock('@nx/devkit');
495-
});
496-
497-
it('should filter coverage paths by project names', async () => {
498-
const allResults = await getNxCoveragePaths(['unit-test']);
499-
const filteredResults = await getNxCoveragePaths(['unit-test'], ['cli']);
500-
501-
expect(allResults).toHaveLength(2); // cli and core
502-
expect(filteredResults).toHaveLength(1); // only cli
503396
});
504397
});

0 commit comments

Comments
 (0)