Comments (4)
Hi @nicojs , thank you very much for your feedback.
Finally I removed the stylesUrls
metadata and test the selector with:
it(`should be selected with 'portal-root' selector`, async(() => {
const metadata = AppComponent['__annotations__'][0];
expect(metadata.selector).toBe('portal-root');
}));
I like your suggestion of an integration test that creates an <portal-root>
. I will implement that test.
You have 100% convinced me about testing the component metadata.
Stryker is such an awesome tool 👍 .
from angular-stryker-example.
Hi @simbas thanks for your feedback!
This issue makes me happy. The angular "metadata" (its not exactly metadata IMHO) is exactly the reason to use mutation testing. We can alter the styles url and selector without breaking any tests. So why is the code there? If it's useless code, it should be removed. If it's useful code it should tested. In this case:
- Indeed the styles url in this example could be removed.
- The selector is required and thus I would expect it to be tested. You could for example create a unit test that verifies the selector name. Or you could create an integration test that creates an
<app>
element and makes sure the app is loaded correctly.
I will not change the code in this example project, because it uses the default angular-cli template. Apparently the default project everyone gets at the beginning has a low mutation score, they could fix that by adding some tests.
from angular-stryker-example.
Hello @nicojs , I'm dealing with this situation also, but in my case, I need to make use of the "stylesUrls".
With the example that @simbas provided I was not able to solve it because styleUrls will become "style" in the metadata.
Any idea how to achive a unit test for styleUrls?
thanks in advance
from angular-stryker-example.
Since stryker-karma-runner 0.16.1, the angular cli is actually native supported. If you use that setup, the style urls changes are reported as a runtime error and thus ignored for mutation score calculation.
Note: you need to update to angular cli 6.1.x for it to work.
from angular-stryker-example.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-stryker-example.