所以下面的代码在test.spec.ts中对我有效:
//@ts-check
import { test, request } from '@playwright/test'
test('api test - to see if Playwright API calls are working', async ({ request }) => {
const response = await request.get(`https://catfact.ninja/fact`);
const statusCode = response.status()
const responseBody = JSON.parse(await response.text())
)}
所以我想在一个单独的模块中提取这个调用。我试着在单独的文件:
import { request } from '@playwright/test';
export async function getCatInfo() {
const response = await request.get(`https://catfact.ninja/fact`)
}
在VS代码中出现错误:Property 'get' does not exist on type 'APIRequest'
我做错了什么?
1条答案
按热度按时间omqzjyyz1#
您应该从
playwright/test
导入: