hirezio / auto-spies

Create automatic spies from classes
MIT License
181 stars 30 forks source link

Angular 12 breaks jasmine-auto-spies@6.9.3 (at least for me) #50

Closed gestj closed 3 years ago

gestj commented 3 years ago

After updating my project to Angular 12 I get this during startup of the tests (with ng test).

./node_modules/err-object/src/index.js:1:0-23 - Error: Module not found: Error: Can't resolve 'util' in '/home/vsts/work/1/s/node_modules/err-object/src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
    - add a fallback 'resolve.fallback: { "util": require.resolve("util/") }'
    - install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
    resolve.fallback: { "util": false }

npm ls err-object gives me this

└─┬ jasmine-auto-spies@6.9.3
  └─┬ @hirez_io/auto-spies-core@1.6.2
    └─┬ code-stringify@2.0.3
      └── err-object@4.5.0 

I didn't try out an entirely new project yet. But after removing jasmine-auto-spies from the project completely tests run again.

I guess its because of the CLI updates due to Angular 12. They updated to webpack 5.

I gave it also a try with installing util manually but then very strange errors occurred so I quickly reverted that change.

I didn't dive much deeper into the topic since removing jasmine-auto-spies fixes it.

=> https://github.com/angular/angular-cli/releases/tag/v12.0.0

Grilly commented 3 years ago

I have integrated jasmine-auto-spies in all my unit tests (~1800) with Angular 11. Upgrading to Angular 12 returned into the same errors as mentioned above.

Unfortunately I also found no workaround but it seams to be a problem with the webpack 5.

@shairez could you please help?

shairez commented 3 years ago

@gestj @Grilly Thanks for the report! I'll have time to look at it on Wednesday / Thursday

Maybe @GuilleEneas or @meksof could help in the meantime?

GuilleEneas commented 3 years ago

Sorry @shairez, I am quite busy lately, I can't promise anything. I let you know if I can find some time to check it sooner

meksof commented 3 years ago

Hi guys, Sorry guys, these days a bit busy. From here next August I will get some free time to work on this issue.

Have a great day.

Le sam. 29 mai 2021 à 20:28, Guille Eneas Timón Grau < @.***> a écrit :

Sorry @shairez https://github.com/shairez, I am quite busy lately, I can't promise anything. I let you know if I can find some time to check it sooner

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hirezio/auto-spies/issues/50#issuecomment-850878403, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLIX6XDFIZ24QXRZT4HVJDTQEW3LANCNFSM45DPQI3Q .

raman-nbg commented 3 years ago

It seems that this also happens with other libraries: https://github.com/angular/angular-cli/issues/20819

shairez commented 3 years ago

Should be fixed now

let me know if the problem continues

alexander-merz commented 3 years ago

@shairez

In my case I had the same error message as @gestj when running my tests. After installing v6.9.5 the error message changed to:

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
    - add a fallback 'resolve.fallback: { "buffer": require.resolve("buffer/") }'
    - install 'buffer'
If you don't want to include a polyfill, you can use an empty module like this:
    resolve.fallback: { "buffer": false }

npm install buffer did the trick for me. Can it be solved the same way as it has been with util?

shairez commented 3 years ago

@alexander-merz Thanks!

I just re-tested it with a clean angular 12 install and I don't see this error.

2 options I can think of -

  1. Try to delete node_modules and reinstall

  2. Maybe you have another library as a dependency which uses buffer... You can run yarn why buffer to see who's using it

let me know how it goes

alexander-merz commented 3 years ago

@shairez It was indeed another library's dependency. Thank you!

shairez commented 3 years ago

@alexander-merz sure thing buddy!