无法运行剧作家测试

soc*_*way 5 javascript npm playwright

我尝试playwright从以下位置运行测试,但它显示消息npm install -D @playwright/test并且无法运行测试。我已经安装playwright为开发依赖项。有人可以告诉我这里有什么问题吗?

我尝试过以下运行:

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
Run Code Online (Sandbox Code Playgroud)
  1. 测试用户@TestUser MINGW64 /c/Test $ npx playwright test 请安装@playwright/test 包以使用Playwright Test。npm install -D @playwright/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');
});
Run Code Online (Sandbox Code Playgroud)

//包.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"
}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

Дми*_*нов 1

我看到有人在这里推荐了一些建议

  1. 删除剧作家模块。

    npm rm playwright

    npm install @playwright/test -D

  2. 使用纱线 npx playwright test->yarn playwright test

  3. 我通过将其添加到我的.gitlab-ci.yml.

cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
    - node_modules/
Run Code Online (Sandbox Code Playgroud)