kolodny / safetest

MIT License
1.31k stars 31 forks source link

satetest/ng + Invalid URL #13

Closed MartinFerret closed 3 months ago

MartinFerret commented 3 months ago
  1. In my file.safetest.ts, we have this import :

import { makeSafetestBed } from 'safetest/ng';

Throws this error : TS2307: Cannot find module safetest/ng or its corresponding type declarations

Where does this module come from and how to fix this issue ?

  1. Also, after running the command npm run safetest, I get :

image I'm running it on localhost obviously, Angular 17. My script :

"safetest": "cross-env OPT_URL=${OPT_URL:-http://localhost:4200} jest --runInBand --bail=5 --testMatch '**/*.safetest.ts' --setupFilesAfterEnv ./setup-safetest.js --testTimeout=30000"

kolodny commented 3 months ago

I just pushed a change to the fix-windows branch. Can you try again. I was able to get this to work on my windows machine using the vanilla command prompt. You'll need to

kolodny commented 3 months ago

If you're talking about using SafeTest in you own project and you're using npm install safetest then it should be available via this export in package.json

You can see the code on the npm page image

kolodny commented 3 months ago

Oh looking at over the issue again, on windows you need to change

OPT_URL=${OPT_URL:-http://localhost:4200}

to

OPT_URL=http://localhost:4200

The ${OPT_URL:-http://localhost:4200} only works on nix based systems

MartinFerret commented 3 months ago

Thanks a lot for the explanations, it works regarding the target URL like a charm, setting the url in the setup file is perfect.

Nonetheless, I still have the issue where I can't import the right lib, which is strange cause as you mentionned below, we see that is available, here is what I have when I want to import :

image

By choosing safetest/lib/ng, by running my tests it gives the following error :

image

Effectively, I'm installing it in a project to fully test it :)

kolodny commented 3 months ago

Hmm, this is an issue with your tooling not following the exports field, that's why there's all these top level files like /react.js just to point to the lib one. I'll need to push a release with an ng file as well. For now you should be able to // @ts-ignore it

kolodny commented 3 months ago

I just published 0.1.12 release which has this file, can you give that a try?

MartinFerret commented 3 months ago

That's solved it, thanks a lot for your help and guiding @kolodny