Giter Club home page Giter Club logo

Comments (8)

MartinNuc avatar MartinNuc commented on June 13, 2024 1

Let me do research how people write integration tests in Angular first :-)

from spectator.

NetanelBasal avatar NetanelBasal commented on June 13, 2024

Why do you need the router in services? Why not mock it? I'm guessing you aren't testing the router implementation.

from spectator.

MartinNuc avatar MartinNuc commented on June 13, 2024

I think my problem is mixing unit tests (there you mock Router) and integration tests (there you try to use RouterTestingModule). I use TestBed (and therefore Spectator) for both.

How do you write integration tests?

from spectator.

NetanelBasal avatar NetanelBasal commented on June 13, 2024

I don't :). I have no problem adding your suggestion.

from spectator.

MartinNuc avatar MartinNuc commented on June 13, 2024

In documentation there is only one note about integration tests: https://angular.io/guide/testing#when-would-i-put-specs-in-a-test-folder

I also found an article saying that we should place integration tests in a file with special name *.integration.spec.ts: https://christianlydemann.com/complete-guide-to-angular-testing/

But there is no recommended way how to write them.

If we wanted to avoid mocking and mimicking the whole Router we really need that RouterTestingModule.

Therefore if you dont mind I will create PR which allows declarations also for createService.

from spectator.

NetanelBasal avatar NetanelBasal commented on June 13, 2024

No problem.

from spectator.

MartinNuc avatar MartinNuc commented on June 13, 2024

Tried to prepare test of a service integrating with Router just by listening to router.events but it doesn't emit anything. So I guess RouterTestingModule contains some kind of incomplete mock of Router.

I didn't come up with another case of using declarations array for a service than integration with router so I will close this issue and we can reopen it when another case comes up.

I was also considering a service using a dynamic component from entryComponents but that doesn't related to declarations either.

from spectator.

MartinNuc avatar MartinNuc commented on June 13, 2024

New issue here: #106

from spectator.

Related Issues (20)

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.