小编Ant*_*ras的帖子

错误:找不到模块“@playwright/test”

我目前正在尝试使用 Expect 来进行断言const { expect } = require('@playwright/test');,但每次我都会收到错误:找不到模块“@playwright/test”。这是一个非常短的脚本,但有些问题。

const { chromium } = require("playwright");
const { expect } = require('@playwright/test');
const { matchers } = require('playwright-expect');
console.log("##########", expect)

// add custom matchers
expect.extend(matchers);

(async () => {
  const browser = await chromium.launch({
    headless: false,
  });
  const page = await browser.newPage();
  await page.goto("someurl");
  await page.fill("input[name='userLoginId']", 'nnn');
  await page.fill("input[name='password']", 'nnn');
  await page.click("button[type=submit]");
})();
Run Code Online (Sandbox Code Playgroud)

包.json

{
  "name": "playwright",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "node ./index.js"
  },
  "keywords": …
Run Code Online (Sandbox Code Playgroud)

javascript node.js playwright playwright-test

7
推荐指数
1
解决办法
3万
查看次数

标签 统计

javascript ×1

node.js ×1

playwright ×1

playwright-test ×1