Git Product home page Git Product logo

Comments (4)

simbas avatar simbas commented on May 27, 2024 2

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.

nicojs avatar nicojs commented on May 27, 2024

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.

pedrotainha avatar pedrotainha commented on May 27, 2024

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.

nicojs avatar nicojs commented on May 27, 2024

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.

See https://github.com/stryker-mutator/stryker/tree/master/packages/stryker-karma-runner#configure-angular-cli

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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.