nest-e2e-sample icon indicating copy to clipboard operation
nest-e2e-sample copied to clipboard

Possible incorrect filename `index.spec.ts`

Open rohanrajpal opened this issue 3 years ago • 1 comments

Hey Jay, thanks a ton for this repository. I've learned a lot of new things through this.

When I run pnpm test:e2e

❯ pnpm test:e2e                                                                                                      (base) 

> [email protected] test:e2e /Users/rohanrajpal/Documents/experiments/nest-e2e-sample
> uvu -r @swc/register test \.e2e-spec\.ts$


  Total:     0
  Passed:    0
  Skipped:   0
  Duration:  0.44ms

But if I rename index.spec.ts to index.e2e-spec.ts then all tests work fine and run as expected. I guess its a typo in the filename?

I had a few more doubts, it'd be great if an expert like you can help me out with them!

  1. This setup fails if I have a dependency injection & seems like the issue is yet to be fixed. 1.1 The issue is related to https://github.com/swc-project/swc/issues/3521 1.2 Were you able to find a workaround to this?
  2. My project has absolute imports like src/prisma & uvu returns file not found for that. I've read the uvu docs and looks like the only way around to specify two folders in the dir argument like src|test probably?

rohanrajpal avatar Jul 01 '22 11:07 rohanrajpal

From the README

If all you're looking to do is run the tests and see it all works, just run node -r @swc/register test/index.spec.ts

Though I suppose I should set up an actual named script for this so that running something like test:e2e works correctly. Forgot about that when setting up the repo. I did keep the name as index.spec.ts on purpose though, so I just need to update the test:e2e script

This setup fails if I have a dependency injection & https://github.com/swc-project/jest/issues/4#issuecomment-1030982259.

For this, I ended up just using the string name of the class, kind of annoying though

uvu returns file not found for that.

This is actually node returning it, because uvu is just a JS library. I set up my .swcrc to handle the paths so that node would know how to interpret them, as seen in another project of mine

jmcdo29 avatar Jul 01 '22 15:07 jmcdo29