我目前正在尝试使用 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)