From 9f942082436eb5280ef07e4cc8cee614b52980c1 Mon Sep 17 00:00:00 2001 From: Nikita Zyulyaev Date: Thu, 22 Jun 2023 15:05:26 +0100 Subject: [PATCH] Fix extra args not being passed to jest --- src/util/getCliOptions.test.ts | 7 +++++++ src/util/getCliOptions.ts | 6 ++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/util/getCliOptions.test.ts b/src/util/getCliOptions.test.ts index ae4d2726..dd300f49 100644 --- a/src/util/getCliOptions.test.ts +++ b/src/util/getCliOptions.test.ts @@ -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); + }); }); diff --git a/src/util/getCliOptions.ts b/src/util/getCliOptions.ts index 9e098a5b..842014d0 100644 --- a/src/util/getCliOptions.ts +++ b/src/util/getCliOptions.ts @@ -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: { @@ -63,7 +61,7 @@ export const getCliOptions = (): CliOptions => { }, defaultOptions); if (extraArgs.length) { - finalOptions.jestOptions.push(...[extraArgs]); + finalOptions.jestOptions.push(...extraArgs); } return finalOptions;