Closed
Description
I've got some topics where this question rised but no correct answer or fix.
If I try e2e tests in monorepo application they are failed because not resolved imports in main application.
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
- Use project example by link
- execute build
npm i
(it should be successful) - start e2e tests
npm run test:e2e
npm run test:e2e
> [email protected] test:e2e
> jest --config ./apps/04-monorepo-apps-libs/test/jest-e2e.json
FAIL apps/04-monorepo-apps-libs/test/app.e2e-spec.ts
● Test suite failed to run
Cannot find module '@app/database' from 'app.module.ts'
2 | import { AppController } from './app.controller';
3 | import { AppService } from './app.service';
> 4 | import { DatabaseModule } from '@app/database';
| ^
5 |
6 | @Module({
7 | imports: [DatabaseModule],
at Resolver.resolveModule (../../../node_modules/jest-resolve/build/index.js:259:17)
at Object.<anonymous> (../src/app.module.ts:4:1)
Test Suites: 1 failed, 1 total
Expected behavior
My expectation is that test should not be failed because unresolved module dependency
import { DatabaseModule } from '@app/database';
because it was resolved at build time.
Minimal reproduction of the problem with instructions
- Use project example by link
- it was generated by
nest-cli
- i faced with similar situation on different OS (mac windows10, ubuntu18) trying migrate my application to
monorepo
configuration - the project example is not mine but it was generated using
nest-cli
and perfectly demonstrates my issues also;
- it was generated by
- execute build
npm i
(it should be successful) - start e2e tests
npm run test:e2e
P.S.
I tried reconfiguretest/jest-e2e.json
to fix the issue but unsuccessfully.
What is the motivation / use case for changing the behavior?
nest g lib SHARED_LIB
or
nest g app OTHER_APP_NAME
Environment
nest info
_ _ _ ___ _____ _____ _ _____
| \ | | | | |_ |/ ___|/ __ \| | |_ _|
| \| | ___ ___ | |_ | |\ `--. | / \/| | | |
| . ` | / _ \/ __|| __| | | `--. \| | | | | |
| |\ || __/\__ \| |_ /\__/ //\__/ /| \__/\| |_____| |_
\_| \_/ \___||___/ \__|\____/ \____/ \____/\_____/\___/
[System Information]
OS Version : macOS Catalina
NodeJS Version : v15.8.0
NPM Version : 7.5.1
[Nest CLI]
Nest CLI Version : 6.14.0
[Nest Platform Information]
platform-express version : 6.7.2
common version : 6.7.2
core version : 6.7.2
Metadata
Metadata
Assignees
Labels
No labels