Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
gestj opened this issue May 18, 2021 · 10 comments
Closed

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

gestj opened this issue May 18, 2021 · 10 comments
Labels

Comments

@gestj
Copy link
Contributor

gestj commented May 18, 2021

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

@gestj gestj changed the title Angular 12 breaks jasmine-auto-spies@6.9.3 Angular 12 breaks jasmine-auto-spies@6.9.3 (at least for me) May 18, 2021
@Grilly
Copy link

Grilly commented May 28, 2021

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
Copy link
Member

shairez commented May 28, 2021

@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?

@shairez shairez added the bug label May 28, 2021
@GuilleEneas
Copy link
Contributor

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
Copy link
Contributor

meksof commented May 30, 2021 via email

@raman-nbg
Copy link

It seems that this also happens with other libraries: angular/angular-cli#20819

@shairez shairez closed this as completed in 2e2f6a7 Jun 9, 2021
@shairez
Copy link
Member

shairez commented Jun 9, 2021

Should be fixed now

let me know if the problem continues

@alexander-merz
Copy link

alexander-merz commented Jun 11, 2021

@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
Copy link
Member

shairez commented Jun 11, 2021

@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

@shairez shairez reopened this Jun 11, 2021
@alexander-merz
Copy link

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

@shairez
Copy link
Member

shairez commented Jun 14, 2021

@alexander-merz sure thing buddy!

@shairez shairez closed this as completed Jun 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants