1

I have switched to Playwright recently and I would like to ask you for some feedback on my current issue which I am facing at the moment.

I have a simple framework set up for one of our company applications. Inside the framework there is a folder structure for Page Object Models with their Components and tests have their own structure. Automated tests are divided into Smoke Test Suite folder and Regression Test Suite folder. I have created a simple "Test" script so it allows to me execute all automated test cases. However I would like to know if there is a way of setting up the script configuration so when I type in console for example npm Test Smoke Suite or npm Test Regression Suite only of will be executed.

Regards and thanks in advance

3

That depends on what exactly you use. Playwright could be used with jest, mocha, ...

Some examples with mocha:

package.json:

"scripts": {
    "smoke-test": "mocha tests/smoke-tests",
    "regression-test": "mocha tests/regression-tests"
}

then you'd run e.g. $ npm run smoke-test and only tests in ./tests/smoke-tests directory will be executed. Make sure you don't override this setting in e.g. .mocharc.json (spec parameter).

Or you can "tag" tests:

test('Open homepage @retired', async function () {
    // some tests steps
});

and execute all tests without a tag:

package.json:

"scripts": {
    "test-not-retired": "mocha -i --grep @retired"
}

There're probably more options how to select only a subset of tests to run.

Another way of setting this up is in e.g. .mocharc.json as I hinted at above.


Jest will have similar options, I'm sure. I'll leave you to it, you can search on the internet as well and experiment a bit.

Of course, if you use a different set-up, my answer could not apply easily. In that case, you'd need to be more specific in your question.

3
  • 1
    Cheers for the answer and yes you are right. I forgot that to add that I am using Mocha as a test runner, I will know better next time. It is good to know that such solution is possible for my current set up. – Automation_Padawan Apr 22 at 11:32
  • Forgot to add in previous comment. What did you mean by .mocharc.json example? Is it a file inside a mocha lib that you can configure as well? Cheers! – Automation_Padawan Apr 22 at 13:00
  • 1
    Please see the docs: mochajs.org/#-config-path => mochajs.org/#configuring-mocha-nodejs You have more options, not only .mocharc.json, that's just what I use. – pavelsaman Apr 22 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.