如何使用NX将E2E测试添加到现有存储库中?

发布于 2025-02-12 01:17:19 字数 770 浏览 1 评论 0原文

在教程视频中,我可以看到,当他创建一个新项目时,NX还为E2E测试用例创建了同级储备。

https://nx.dev/reaect.dev/react-tutorial/01-create-create-create-application

我的问题是,我有一个已经创建的MonorePo,它具有这样的结构。前端是使用npx-create-react-app ...

MyApp
 - FrontEndRepo
 - BackEndRepo

根据nx公约 nrwl nx为什么要为每个应用程序创建一个单独的E2E项目?

如果我开始使用它创建我的项目,则应该是这样的。

MyApp
     - FrontEndRepo
     - FrontEndRepo-e2e
     - BackEndRepo
     - BackEndRepo-e2e

那么,如何将这些E2E测试文件夹添加到现有存储库中呢?

In the tutorial video, I can see that when he created a new project NX also create a sibling repo for e2e test cases.

https://nx.dev/react-tutorial/01-create-application

My question is that I got a monorepo which I already created, which have a structure like this. front end was created with npx-create-react-app ...

MyApp
 - FrontEndRepo
 - BackEndRepo

According to NX convention Why does nrwl nx create a separate e2e project for each app?

If I start creating my project with it should be something like this.

MyApp
     - FrontEndRepo
     - FrontEndRepo-e2e
     - BackEndRepo
     - BackEndRepo-e2e

So how can I add those e2e test folders to existing repo?

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

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

发布评论

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

评论(2

予囚 2025-02-19 01:17:19

最简单的是只需在每个-e2e文件夹中创建一个项目结构,然后在两个地方安装柏树。

要从根部运行前端或后端测试,请在package.json中添加两个脚本,更改每个脚本。

cypress.config.js在每个-e2e文件夹中是特定于该项目要求的,例如API URL等。

{
  ...
  "scripts": {
    ...
    "test:fe": "cypress open --config-file FrontEndRepo-e2e/cypress.config.js",
    "test:be": "cypress open --config-file BackEndRepo-e2e/cypress.config.js",

The simplest is to just create a project structure in each -e2e folder and install Cypress in both places.

To run front-end or back-end tests from the root, add two scripts in package.json, changing the config file reference in each one.

The cypress.config.js in each -e2e folder is specific to the requirements of that project, e.g API url etc.

{
  ...
  "scripts": {
    ...
    "test:fe": "cypress open --config-file FrontEndRepo-e2e/cypress.config.js",
    "test:be": "cypress open --config-file BackEndRepo-e2e/cypress.config.js",

手心的海 2025-02-19 01:17:19

使用nx为您生成它:

npx nx generate @nrwl/cypress:cypress-project frontEndRepo-e2e -project = frontendEndRepo

Use Nx to generate it for you:

npx nx generate @nrwl/cypress:cypress-project FrontEndRepo-e2e --project=FrontEndRepo

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