Skip to content

Commit 6c657a5

Browse files
committed
test(plugin-eslint): fix unit tests and lint
1 parent fd29da9 commit 6c657a5

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

packages/plugin-eslint/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"dependencies": {
4141
"@code-pushup/utils": "0.74.1",
4242
"@code-pushup/models": "0.74.1",
43+
"glob": "^11.0.0",
4344
"yargs": "^17.7.2",
4445
"zod": "^4.0.5"
4546
},

packages/plugin-eslint/src/lib/runner/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export async function loadArtifacts(
3434
? artifacts.artifactsPaths
3535
: [artifacts.artifactsPaths];
3636

37-
const artifactPaths = await glob(initialArtifactPaths, options);
37+
const artifactPaths = await glob(initialArtifactPaths);
3838

3939
ui().logger.log(
4040
`ESLint plugin resolved ${initialArtifactPaths.length} ${pluralizeToken('pattern', initialArtifactPaths.length)} to ${artifactPaths.length} eslint ${pluralizeToken('report', artifactPaths.length)}`,

packages/plugin-eslint/src/lib/runner/utils.unit.test.ts

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,7 @@ describe('loadArtifacts', () => {
8787
});
8888

8989
it('should load multiple artifacts without generateArtifactsCommand', async () => {
90-
globSpy
91-
.mockResolvedValueOnce([artifactsPaths.at(0)!])
92-
.mockResolvedValueOnce([artifactsPaths.at(1)!]);
90+
globSpy.mockResolvedValue(artifactsPaths);
9391
readJsonFileSpy
9492
.mockResolvedValueOnce(mockRawResults1)
9593
.mockResolvedValueOnce(mockRawResults2);
@@ -99,9 +97,8 @@ describe('loadArtifacts', () => {
9997
expectedLinterOutput2,
10098
]);
10199

102-
expect(globSpy).toHaveBeenCalledTimes(2);
103-
expect(globSpy).toHaveBeenNthCalledWith(1, artifactsPaths.at(0));
104-
expect(globSpy).toHaveBeenNthCalledWith(2, artifactsPaths.at(1));
100+
expect(globSpy).toHaveBeenCalledTimes(1);
101+
expect(globSpy).toHaveBeenCalledWith(artifactsPaths);
105102
expect(readJsonFileSpy).toHaveBeenCalledTimes(2);
106103
expect(readJsonFileSpy).toHaveBeenNthCalledWith(1, artifactsPaths.at(0));
107104
expect(readJsonFileSpy).toHaveBeenNthCalledWith(2, artifactsPaths.at(1));
@@ -110,9 +107,7 @@ describe('loadArtifacts', () => {
110107
});
111108

112109
it('should load artifacts with generateArtifactsCommand as string', async () => {
113-
globSpy
114-
.mockResolvedValueOnce([artifactsPaths.at(0)!])
115-
.mockResolvedValueOnce([artifactsPaths.at(1)!]);
110+
globSpy.mockResolvedValue(artifactsPaths);
116111
readJsonFileSpy.mockResolvedValue([]);
117112

118113
const generateArtifactsCommand = `nx run-many -t lint --parallel --max-parallel=5`;
@@ -128,14 +123,13 @@ describe('loadArtifacts', () => {
128123
command: generateArtifactsCommand,
129124
ignoreExitCode: true,
130125
});
131-
expect(globSpy).toHaveBeenCalledTimes(2);
126+
expect(globSpy).toHaveBeenCalledTimes(1);
127+
expect(globSpy).toHaveBeenCalledWith(artifactsPaths);
132128
expect(ui()).toHaveLogged('log', `$ ${generateArtifactsCommand}`);
133129
});
134130

135131
it('should load artifacts with generateArtifactsCommand as object', async () => {
136-
globSpy
137-
.mockResolvedValueOnce([artifactsPaths.at(0)!])
138-
.mockResolvedValueOnce([artifactsPaths.at(1)!]);
132+
globSpy.mockResolvedValue(artifactsPaths);
139133
readJsonFileSpy.mockResolvedValue([]);
140134

141135
const generateArtifactsCommand = {
@@ -153,7 +147,8 @@ describe('loadArtifacts', () => {
153147
...generateArtifactsCommand,
154148
ignoreExitCode: true,
155149
});
156-
expect(globSpy).toHaveBeenCalledTimes(2);
150+
expect(globSpy).toHaveBeenCalledTimes(1);
151+
expect(globSpy).toHaveBeenCalledWith(artifactsPaths);
157152
expect(ui()).toHaveLogged(
158153
'log',
159154
'$ nx run-many -t lint --parallel --max-parallel=5',

0 commit comments

Comments
 (0)