如何在子文件夹中组织代码接收测试,并让一个 codecept.conf.js 指向整个文件夹架构

发布于 2025-01-14 06:31:13 字数 929 浏览 4 评论 0原文

我遇到问题,在我的 codecept 配置中的“./acceptance_tests.js/*_tests.js”路径名中创建子文件夹。

即我的 codecept.conf.js 看起来像这样:

  exports.config = {
  tests: './acceptance_tests/*_test.js',
  output: './output' ....

当 conf.js 文件设置为此时,我可以毫无问题地运行在 Acceptance_test 文件路径内的测试。当我尝试创建一个子文件夹来组织我的测试时,即 Acceptance_test >帐户_测试> (测试) 或者 验收测试>注册测试> (测试)。

我无法调用这些测试,因为conf 文件正在acceptance_test 文件夹中查找所有“*test.js”文件。

我可以更改conf文件中的路径以显式指向每个子文件夹,但似乎必须有更好的方法来做到这一点。因为每次我想在另一个子文件夹中运行测试时,我都必须更改文件路径。

我试图将其指向

'./acceptance_tests/randome_subfolder_Name/*_test.js'

'*_test.js'

'./acceptance_tests/*/*_test.js'

但似乎无法让它运行位于acceptance_test文件夹中的那些子文件夹中的所有子文件夹或测试。我曾尝试在运行测试时手动调用整个路径,就像这样

Npm run codeceptjs  './acceptance_tests/random_subfolder_Name/andomTest_test.js'

,但这也不起作用。但是,当我进行该测试并将其放入 Acceptance_test 的父文件夹中时,它确实有效。

任何帮助将不胜感激。

I'm having issues, creating subfolders in my './acceptance_tests.js/*_tests.js' pathname within my codecept config.

I.e. My codecept.conf.js looks like this:

  exports.config = {
  tests: './acceptance_tests/*_test.js',
  output: './output' ....

I can run tests no problem that are within acceptance_test file path when the conf.js file is set to this. When I try to create a sub-folder to organize my tests i.e. acceptance_test > account_test > (tests)
or
acceptance_test > registration_test > (tests).

I am unable to call those tests, since the conf file is looking for all '*test.js' file within the acceptance_test folder.

I can change the path in the conf file to explicitly point to each subfolder, but it seems there must be a better way to do this. Since I would have to change the file path each time I wanted to run tests in another subfolder.

I have tried to point it to

'./acceptance_tests/randome_subfolder_Name/*_test.js'

'*_test.js'

'./acceptance_tests/*/*_test.js'

But cant seem to get it to run all subfolders or tests within those subfolders sitting within acceptance_test folder. I have tried manually calling out the whole path when running the test like so

Npm run codeceptjs  './acceptance_tests/random_subfolder_Name/andomTest_test.js'

And that doesn't work either. But the moment I take that test and drop it in the parent folder of acceptance_test - it does work.

Any help would be much appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

淡看悲欢离合 2025-01-21 06:31:13

在配置文件中,您可以指定它来查看子文件夹,

exports.config = {
tests: './acceptance_tests/**/*_test.js',
output: './output' ....

'**' 

跨越acceptance_tests下的所有子文件夹

In the config file you can specify it to look through subfolders with this

exports.config = {
tests: './acceptance_tests/**/*_test.js',
output: './output' ....

With the

'**' 

spanning through all subfolders under acceptance_tests

浅暮の光 2025-01-21 06:31:13

如果手动选择配置文件,您可以从任何文件夹运行测试,例如:

npx codeceptjs run --grep "test name" --config=tests/codecept.conf.js

在我的例子中,所有测试的配置文件位于测试文件夹中

you can run tests from any folder if you select config file manually, for example:

npx codeceptjs run --grep "test name" --config=tests/codecept.conf.js

in my case config file for all tests is located in the tests folder

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文