yarn add cypress --dev
- Typescript
| import { fakeAsync, tick } from '@angular/core/testing'; | |
| import { Observable } from 'rxjs/Observable'; | |
| import { SomeComponent } from './some.component'; | |
| describe('SomeComponent:', () => { | |
| let component: SomeComponent; | |
| let mockDepThree: any; | |
| beforeEach(() => { |
| import { SomeComponent } from './some.component'; | |
| describe('SomeComponent:', () => { | |
| let component: SomeComponent; | |
| beforeEach(() => { | |
| component = new SomeComponent(); | |
| }); | |
| describe('returnSomeObservable', () => { |
| import { SomeComponent } from './some.component'; | |
| describe('SomeComponent:', () => { | |
| let component: SomeComponent; | |
| beforeEach(() => { | |
| component = new SomeComponent(); | |
| }); | |
| describe('returnSomeObservable', () => { |
| import { SomeComponent } from './some.component.js'; | |
| describe('SomeComponent:', () => { | |
| let component: SomeComponent; | |
| let mockDepOne: any; | |
| let mockDepTwo: any; | |
| beforeEach(() => { | |
| mockDepOne = { | |
| doSomething: jasmine.createSpy('doSomething').and.returnValue('0123456789') |
| import { SomeComponent } from './some.component'; | |
| describe('SomeComponent:', () => { | |
| let component: SomeComponent; | |
| let mockDepOne: any; | |
| beforeEach(() => { | |
| mockDepOne = { | |
| doSomething: () => '0123456789' // We correctly define a return value for our mock... | |
| }; |
| describe('SomeComponent:', () => { | |
| describe('someMethod', () => { | |
| describe('true', () => { | |
| it('should call depOne.doSomething', () => { | |
| }); |
| import { SomeComponent } from './some.component.js'; // only import the thing you want to test | |
| describe('SomeComponent:', () => { | |
| let component: SomeComponent; | |
| let mockDepOne: any; // do not import DepOne, 'any' it | |
| let mockDepTwo: any; // do not import DepTwo, 'any' it | |
| let mockDepThree: any; // do not import DepThree, 'any' it | |
| beforeEach(() => { |
| describe('SomeComponent:', () => { | |
| describe('when someMethod is called', () => { | |
| describe('and someCondition is true', () => { | |
| it('then something should happen', () => { | |
| // expect: something to happen | |
| }); | |
| }); | |
| }); | |
| }); |