Skip to content

Commit

Permalink
Fix extra args not being passed to jest
Browse files Browse the repository at this point in the history
  • Loading branch information
zyulyaev committed Jun 22, 2023
1 parent 2aa338d commit 9f94208
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/util/getCliOptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,11 @@ describe('getCliOptions', () => {
const opts = getCliOptions();
expect(opts.runnerOptions).toMatchObject(customConfig);
});

it('returns extra args if passed', () => {
const extraArgs = ['TestName', 'AnotherTestName'];
jest.spyOn(cliHelper, 'getParsedCliOptions').mockReturnValue({ options: {}, extraArgs });
const opts = getCliOptions();
expect(opts.jestOptions).toEqual(extraArgs);
});
});
6 changes: 2 additions & 4 deletions src/util/getCliOptions.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { getParsedCliOptions } from './getParsedCliOptions';
import type { BrowserType } from 'jest-playwright-preset';

export type JestOptions = {
[key: string]: any;
};
export type JestOptions = any[];

export type CliOptions = {
runnerOptions: {
Expand Down Expand Up @@ -63,7 +61,7 @@ export const getCliOptions = (): CliOptions => {
}, defaultOptions);

if (extraArgs.length) {
finalOptions.jestOptions.push(...[extraArgs]);
finalOptions.jestOptions.push(...extraArgs);
}

return finalOptions;
Expand Down

0 comments on commit 9f94208

Please sign in to comment.