Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switching to the monorepo mode breaks e2e tests #667

Closed
rafsawicki opened this issue Apr 24, 2021 · 3 comments
Closed

Switching to the monorepo mode breaks e2e tests #667

rafsawicki opened this issue Apr 24, 2021 · 3 comments

Comments

@rafsawicki
Copy link

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When a first sub-application is added to the repository and it's automatically converted to the monorepo mode, a jest-e2e.json file is moved to the apps/[application]/test directory. However, a moduleNameMapper section for existing libraries is not changed, which breaks imports when e2e tests are executed.

Expected behavior

A Nest CLI should update moduleNameMapper section when it's moving the jest-e2e.json file, especially when entries that exist there were created by the CLI and were not modified by the user in any way.

Minimal reproduction of the problem with instructions

  1. Generate a new Nest application
nest generate application app
  1. Add a new library
cd app
nest generate library lib
  • src/app.module.ts
import { LibModule } from '@app/lib';
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';

@Module({
  imports: [LibModule],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}
  1. Add a first sub-application
nest generate sub-app app2
  1. Run e2e tests
yarn test:e2e
$ jest --config ./apps/app/test/jest-e2e.json
 FAIL  apps/app/test/app.e2e-spec.ts
  ● Test suite failed to run

    Configuration error:
    
    Could not locate module @app/lib mapped as:
    /tmp/test-repo/app/apps/app/libs/lib/src.
    
    Please check your configuration for these entries:
    {
      "moduleNameMapper": {
        "/@app\/lib/": "/tmp/test-repo/app/apps/app/libs/lib/src"
      },
      "resolver": undefined
    }

    > 1 | import { LibModule } from '@app/lib';

What is the motivation / use case for changing the behavior?

Environment


Nest version: 7.5.1

 
For Tooling issues:
- Node version: v12.16.3  
- Platform:  Linux

Others:

@Tony133
Copy link
Contributor

Tony133 commented Apr 24, 2021

Hi @rafsawicki, I advise you to leave a minimal reproduction of a clonable git repository so that the core team can evaluate the problem you have reported.

@kamilmysliwiec
Copy link
Member

Unfortunately, we currently don't maintain jest configuration in the monorepo mode. This will change once we merge this PR #532 (Jest will use the configuration specified in the tsconfig file)

@rafsawicki
Copy link
Author

I see, thanks for the heads up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants