当使用测试笑话时,开玩笑的测试太多了……不是我想要的测试

发布于 2025-01-22 22:30:19 字数 1049 浏览 0 评论 0原文

由于某种原因,我似乎无法将“柏树,伪造者和开玩笑的单位测试”分为单独的命令:

package.json:

        "test:jest": "jest ./src",
        "e2e:pptr": "npm run dev & jest ./tests",
        "e2e:cypress": "npm run dev & cypress run",
        "e2e:cypress:browser": "npm run dev & cypress open",

...

    "jest": {
        "verbose": true,
        "testEnvironment": "jsdom",
        "transform": {
            "^.+\\.svelte$": [
                "svelte-jester",
                {
                    "preprocess": true
                }
            ],
            "^.+\\.js$": "babel-jest",
            "^.+\\.ts$": "ts-jest"
        },
        "moduleFileExtensions": [
            "js",
            "ts",
            "svelte"
        ],
        "setupFilesAfterEnv": [
            "@testing-library/jest-dom/extend-expect"
        ]
    }

当我运行npm运行测试时:JEST它仍然会运行所有测试。包括柏树和./ tests/*。spec.js文件。它建议仅在./src下进行测试,这是我的单位测试。

Puppeteer测试在/tests/*。Spec.js中,柏树在./ cypress/*

For some reason I can't seem to split out "cypress, puppeteer and jest unit tests" into separate commands:

package.json:

        "test:jest": "jest ./src",
        "e2e:pptr": "npm run dev & jest ./tests",
        "e2e:cypress": "npm run dev & cypress run",
        "e2e:cypress:browser": "npm run dev & cypress open",

...

    "jest": {
        "verbose": true,
        "testEnvironment": "jsdom",
        "transform": {
            "^.+\\.svelte
quot;: [
                "svelte-jester",
                {
                    "preprocess": true
                }
            ],
            "^.+\\.js
quot;: "babel-jest",
            "^.+\\.ts
quot;: "ts-jest"
        },
        "moduleFileExtensions": [
            "js",
            "ts",
            "svelte"
        ],
        "setupFilesAfterEnv": [
            "@testing-library/jest-dom/extend-expect"
        ]
    }

WHen I run npm run test:jest it still runs all tests. including cypress and ./tests/*.spec.js files. Its suppposed to just run tests under ./src which are my unit tests.

puppeteer tests are in ./tests/*.spec.js and cypresss are under ./cypress/*

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

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

发布评论

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

评论(1

︶葆Ⅱㄣ 2025-01-29 22:30:19

因此,我需要添加- rootdir< path>以限制它。

“ test:jest”:“ Jest -rootdir ./src”,

So I needed to add --rootDir <path> to limit it.

"test:jest": "jest --rootDir ./src",

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