mbolotov / intellij-playwright

1 stars 0 forks source link

How can I define the --config flag? #6

Closed zakhenry closed 2 years ago

zakhenry commented 2 years ago

I use NX and so my tests are fairly nested within a folder. The npm script I run to get headed tests is

yarn playwright test --config ./apps/my-app-e2e/playwright.config.ts --headed

I don't have anything special in the config file, but I suspect the testDir: './src/tests', field is what is causing this plugin to fail to find my tests?

Out of the box if I try to run a test from the gutter I get

Screenshot 2022-05-03 at 04 15 30

the console shows

/Users/zak/.nvm/versions/node/v14.17.1/bin/node /Users/zak/.nvm/versions/node/v14.17.1/lib/node_modules/yarn/bin/yarn.js run playwright test --reporter /var/folders/j8/hkdrcxfn7819nyspt0mqq0tm0000gn/T/intellij-playwright-reporter11570315857909753255.js optimize.spec.ts -g "^optimize.spec.ts.Optimize.should have the form initialised$"
yarn run v1.22.15
$ playwright test --reporter /var/folders/j8/hkdrcxfn7819nyspt0mqq0tm0000gn/T/intellij-playwright-reporter11570315857909753255.js optimize.spec.ts -g '^optimize.spec.ts.Optimize.should have the form initialised$'

nothing in that command has the relative path to the spec file so I think the config needs to be passed for discovery (or maybe the plugin can pass the full path directly?)

mbolotov commented 2 years ago

Hi Zak, You can define any additional parameters in this field of a run configuration: image

zakhenry commented 2 years ago

Wouldn't I need to do this on every test though? As in the workflow would be run test in margin, let it fail, go edit run configuration then rerun. for each test?

mbolotov commented 2 years ago

you can use run configuration templates to define default parameters to be used for a newly created configuration: image

zakhenry commented 2 years ago

Oh fantastic, that works well thanks!

rickirunge commented 2 years ago

Also works if you manual change "Project Base" to the root of your project.

Don't know why this is set to the folder of the test being run - don't know when that would be needed? IMO it should (almost) always be the project root - the same ways as when you run playwright using "npm run"