shallow-render
shallow-render copied to clipboard
Runtime performance is very slow compared to native Angular testing
In my project, there are a few problematic component tests that occasionally creep past the 5s limit and cause Jasmine to fail awaiting the result of shallow.render()
.
One such component has 9 tests that take between 14-17 seconds to execute with shallow-render using Jasmine spies. When changing it to use TestBed.configureTestingModule
with the same spies, directly accessing fixture
, the 9 tests take less than one second.
I also just quickly refactored a component test that renders a chart from shallow-render to native Angular testing, and the runtime decreased from around 1.4 seconds to 0.18s.
Is this type of rendering performance discrepancy expected?
Edit: I created a gist to illustrate this, based off of a fresh ng new
project with the default spec deleted:
https://gist.github.com/antch/cc792661d0e9e2c9ce7801856ad01ed6
The only added dependencies are chart.js
and primeng
.
You can comment out each describe
block to see the huge disparity in execution time.