Reputation: 11991
I am trying to run playwright
test from the below location, but it shows the message npm install -D @playwright/test
and unable to run the test. I have already installed playwright
as dev dependency. Could someone please advise what is the issue here ?
I have tried below runs:
1)
Test User@TestUser MINGW64 /c/Test
$ npx playwright test --headed
Please install @playwright/test package to use Playwright Test.
npm install -D @playwright/test
Test User@TestUser MINGW64 /c/Test $ npx playwright test Please install @playwright/test package to use Playwright Test. npm install -D @playwright/test
// test/test1.spec.js
const { test, expect } = require('@playwright/test');
test('basic test', async ({ page }) => {
await page.goto('https://playwright.dev/');
const title = page.locator('.navbar__inner .navbar__title');
await expect(title).toHaveText('Playwright');
});
//package.json
{
"name": "play",
"version": "1.0.0",
"description": "Playwright test",
"main": "index.js",
"directories": {
"test": "test"
},
"dependencies": {},
"devDependencies": {
"@playwright/test": "^1.16.1"
},
"scripts": {
"test": "npx playwright test"
},
"author": "Test",
"license": "ISC"
}
Upvotes: 5
Views: 20217
Reputation: 31
I tried the above solutions but didn't work for me straight forward. I did the below workaround that worked for me
Steps
Upvotes: 0
Reputation: 2553
I saw guys are recommending a couple of suggestions here
Delete the playwright module.
npm rm playwright
npm install @playwright/test -D
Use yarn npx playwright test
-> yarn playwright test
And I solved the issue in my Gitlab pipeline with adding this to my .gitlab-ci.yml
.
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
Upvotes: 2