I have two test files, when I rename and comment one of them, the test will pass successfuly, otherwise will always throw this error:
FAIL src/features/user/auth/register.resolver.test.ts (10.045 s)
● Register › a new user with a valid form › call register resolver and return the registered user
Tests cannot be nested. Test "encountered a declaration exception" cannot run because it is nested within "call register resolver and return the registered user".
28 | `
29 |
> 30 | describe('Login', () => {
| ^
31 | let dbConnection: Connection;
32 | let userRepository: UserRepository;
33 |
at Env.it (node_modules/jest-jasmine2/build/jasmine/Env.js:566:17)
at Object.<anonymous> (src/features/user/auth/login.resolver.test.ts:30:1)
● Register › a new user with a valid form › the new user is persisted in database
expect(received).toMatchObject(expected)
Matcher error: received value must be a non-null object
Received has value: undefined
81 | });
82 |
> 83 | expect(user).toMatchObject({
| ^
84 | id: expect.any(String),
85 | username: registerInput.username,
86 | email: registerInput.email,
at Object.<anonymous> (src/features/user/auth/register.resolver.test.ts:83:20)
● Register › a new user with an invalid form › returns the errors
Tests cannot be nested. Test "encountered a declaration exception" cannot run because it is nested within "returns the errors".
28 | `
29 |
> 30 | describe('Login', () => {
| ^
31 | let dbConnection: Connection;
32 | let userRepository: UserRepository;
33 |
at Env.it (node_modules/jest-jasmine2/build/jasmine/Env.js:566:17)
at Object.<anonymous> (src/features/user/auth/login.resolver.test.ts:30:1)
FAIL src/features/user/auth/login.resolver.test.ts (10.298 s)
● Login › with a valid form › call login resolver and return the logged in user
Tests cannot be nested. Test "encountered a declaration exception" cannot run because it is nested within "call login resolver and return the logged in user".
27 | `
28 |
> 29 | describe("Register", () => {
| ^
30 | let dbConnection: Connection;
31 | let userRepository: UserRepository;
32 |
at Env.it (node_modules/jest-jasmine2/build/jasmine/Env.js:566:17)
at Object.<anonymous> (src/features/user/auth/register.resolver.test.ts:29:1)
● Login › with an invalid form › returns an error [login]
Tests cannot be nested. Test "encountered a declaration exception" cannot run because it is nested within "returns an error [login]".
27 | `
28 |
> 29 | describe("Register", () => {
| ^
30 | let dbConnection: Connection;
31 | let userRepository: UserRepository;
32 |
at Env.it (node_modules/jest-jasmine2/build/jasmine/Env.js:566:17)
at Object.<anonymous> (src/features/user/auth/register.resolver.test.ts:29:1)
Test Suites: 2 failed, 2 total
Tests: 5 failed, 1 passed, 6 total
Snapshots: 0 total
Time: 11.143 s
Ran all test suites.
And here the test files: https://gist.github.com/srgrcp/01fbbd4df391a90c25c8c60622bc2514
If I'm not wrong, the error says: "the is nested within ", but these tests are in different files.