hirezio / auto-spies

Create automatic spies from classes
MIT License
181 stars 30 forks source link

Support for Cypress #57

Open azaeng04 opened 2 years ago

azaeng04 commented 2 years ago

Is your feature request related to a problem? Please describe. So I am using the following library: https://github.com/jscutlery/devkit to write component tests for Angular components. A test is defined with the mount function like so:

mount(MyComponent, {
 providers: [],
...
})

Describe the solution you'd like I would like to be able to make use of auto-spies to be able to mock out return values on services to verify different rendered states of the component visually.

So using this:


    let myServiceSpy: Spy<MyService>;
    provideAutoSpy(MyService),
    myServiceSpy = TestBed.inject<any>(MyService);

inside the

mount(MyComponent, {
 providers: [provideAutoSpy(MyService),],
...
})

and mock the return value later in the test

Describe alternatives you've considered None

Additional context When providing that auto-spy an error is thrown indicating that jasmine or jest is not defined. I am assuming here that we might need to make use of cypress mocking framework, which is Sinon under the hood.

shairez commented 2 years ago

Hi @azaeng04

In order to support cypress we first need to create a port of this library for mocha I'm talking to Jordan Powell from the Cypress team and he needs to get back to me if he thinks it's a good fit

Will update