gpt4 book ai didi

javascript - 剧作家 'no tests found.' 在 example.spec.ts 的简单副本上

转载 作者:行者123 更新时间:2023-12-05 03:29:09 28 4
gpt4 key购买 nike

我刚刚安装了 playwright (v1.18.1) 来试用 (Windows 11),但我觉得有些不对劲。我可以很好地运行 example.spec.ts 脚本,但是如果我复制该文件然后尝试运行副本,那么我会得到一个 no tests found. 错误。

这些步骤看起来很简单......

首先测试运行 C:\playwright\test\tests\example.spec.ts 脚本....

C:\playwright\test\tests>npx playwright test example.spec.ts

Running 25 tests using 1 worker

- example.spec.ts:14:3 › New Todo › should allow me to add todo items
Terminate batch job (Y/N)?

25 skipped

[如此有效] 然后创建一个副本开始播放...

C:\playwright\test\tests>copy example.spec.ts test4.ts
1 file(s) copied.

但在编辑 test4.ts 之前,我检查它是否会运行...

C:\playwright\test\tests>npx playwright test test4.ts

=================
no tests found.
=================
npm ERR! code 1
npm ERR! path C:\playwright\test\tests
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c playwright test test4.ts

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\xxxxx\AppData\Local\npm-cache\_logs\2022-02-09T16_29_19_723Z-debug.log

如果它有助于日志读取:

C:\playwright\test\tests>type C:\Users\xxxxx\AppData\Local\npm-cache\_logs\2022-02-09T16_37_46_149Z-debug.log
0 verbose cli [
0 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
0 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
0 verbose cli 'exec',
0 verbose cli '--',
0 verbose cli 'playwright',
0 verbose cli '-version'
0 verbose cli ]
1 info using npm@7.0.15
2 info using node@v15.4.0
3 timing config:load:defaults Completed in 1ms
4 timing config:load:file:C:\Program Files\nodejs\node_modules\npm\npmrc Completed in 1ms
5 timing config:load:builtin Completed in 2ms
6 timing config:load:cli Completed in 1ms
7 timing config:load:env Completed in 0ms
8 timing config:load:file:C:\playwright\test\.npmrc Completed in 0ms
9 timing config:load:project Completed in 1ms
10 timing config:load:file:C:\Users\xxxxx\.npmrc Completed in 0ms
11 timing config:load:user Completed in 0ms
12 timing config:load:file:C:\Users\xxxxx\AppData\Roaming\npm\etc\npmrc Completed in 0ms
13 timing config:load:global Completed in 0ms
14 timing config:load:cafile Completed in 0ms
15 timing config:load:validate Completed in 1ms
16 timing config:load:setUserAgent Completed in 0ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 7ms
19 verbose npm-session c0bee43e8701d230
20 timing npm:load Completed in 16ms
21 timing command:exec Completed in 633ms
22 verbose stack Error: command failed
22 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\promise-spawn\index.js:64:27)
22 verbose stack at ChildProcess.emit (node:events:376:20)
22 verbose stack at maybeClose (node:internal/child_process:1063:16)
22 verbose stack at Process.ChildProcess._handle.onexit (node:internal/child_process:295:5)
23 verbose pkgid test@1.0.0
24 verbose cwd C:\playwright\test\tests
25 verbose Windows_NT 10.0.22000
26 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "exec" "--" "playwright" "-version"
27 verbose node v15.4.0
28 verbose npm v7.0.15
29 error code 1
30 error path C:\playwright\test\tests
31 error command failed
32 error command C:\WINDOWS\system32\cmd.exe /d /s /c playwright -version
33 verbose exit 1

为什么它只是一个有效的原件的副本时给我一个错误?

最佳答案

您可以设置自己的test match regexplaywright test config .
默认情况下,Playwright Test 会查找匹配 .*(test|spec)\.(js|ts|mjs) 的文件,但您可以通过执行此操作来运行任何 js 文件:

import { PlaywrightTestConfig, devices } from '@playwright/test';

const config: PlaywrightTestConfig = {
testMatch: /.*.js/,
};
export default config;

请记住,它会尝试从您文件夹中的任何帮助文件加载测试。我认为遵循 testspec 约定是一件好事。

关于javascript - 剧作家 'no tests found.' 在 example.spec.ts 的简单副本上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71053528/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com