question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom webpack loaders not applying in unit tests

See original GitHub issue

Describe the bug Adding custom webpack loaders works perfect with ng serve and ng build but it doesn’t work with ng test.

To Reproduce Steps to reproduce the behavior:

  1. Add extra webpack config for Pug templates:
module.exports = {module: {rules: [{test: /.pug$/, use: [{ loader: 'apply-loader' },{ loader: 'pug-loader' }]}]}};
  1. Create pug template. It works good with ng serve
  2. Run ng test. You will see just a plain text instead of components.

OR (preferred way) A link to a repository with minimal reproduction: https://github.com/vadjs/custom-loaders-bug

Expected behavior Custom loaders should work properly during unit tests run.

Builder:

Libraries

  • angular-devkit/build-angular: 8.2.0

Additional context This problem appeared in Angular 8. Looks like Angular team dedicated unit tests config to a different place. That’s not only @angular-builders/custom-webpack bug because replacing common.js file with webpack config in @angular-devkit/build-angular produces the same bug.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
just-jebcommented, Aug 30, 2019

Must be the direct template loading option (which is enabled by default). Try to disable it.

0reactions
kmarazcommented, Jan 21, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

severals issues with my unit test config - Stack Overflow
I'm trying to build unit test for my angularjs es-6 app, using Karma, Webpack and mocha. The source code is under a src...
Read more >
Writing a Loader - webpack
Before we dig into the different types of loaders, their usage, and examples, let's take a look at the three ways you can...
Read more >
How to configure Webpack with React Testing Library from the ...
Then run this command jest. I hope all the test passes on your computer. Some of the modules that we installed were not...
Read more >
Using with webpack - Jest
Jest caches files to speed up test execution. If you updated .babelrc and Jest is not working as expected, try clearing the cache...
Read more >
Angular: Unit test environment configuration with Karma ...
We opted for webpack configurations throughout our apps in our aim to achieve a universal configuration that is not dependent on angular. I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found