我试图从下面的位置运行playwright测试,但它显示了消息npm install -D @playwright/test,无法运行测试。我已经将playwright安装为dev依赖项。有人能告诉我这里有什么问题吗?
我试过以下几种方法:
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/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"
}

发布于 2022-09-26 15:03:22
我看到一些人在推荐一些建议,这里
npm rm playwright
npm install @playwright/test -Dnpx playwright test -> yarn playwright test.gitlab-ci.yml中,我解决了Gitlab管道中的问题。
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
https://stackoverflow.com/questions/69701816
复制相似问题