This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
beforeEach(async () => { | |
TestBed.configureTestingModule({ | |
// 親Container, 子Component | |
declarations: [SampleContainerComponent, SampleComponent], | |
}); | |
await TestBed.compileComponents(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fetch('https://hoge.com/users/1', {method: 'GET'}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import '../mocks/browser'; // add code | |
export const environment = { | |
production: false, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { setupWorker, rest } from 'msw' | |
export const mocks = [ | |
rest.get('https://hoge.com/users/:user', (req, res, ctx) => { | |
const { user } = req.params | |
return res( | |
ctx.status(200), | |
ctx.json({ | |
name: `mocked-${user}`, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 例(myorgは自分のアプリ名) | |
npx msw init apps/myorg/src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm install msw --save-dev | |
# or | |
yarn add msw --dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// appNameは自分のアプリ名 | |
nx g nx-ng-esbuild:add-esbuild-config appName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yarn add -D nx-ng-esbuild |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { StoreModule } from '@ngrx/store'; | |
import { EffectsModule } from '@ngrx/effects'; | |
@NgModule({ | |
declarations: [ | |
StoreModule.forRoot({ LoginState: loginReducer}), // LoginStateはselectorで書いたキー | |
EffectsModule.forRoot([LoginEffects]), | |
], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { Actions, createEffect, ofType } from '@ngrx/effects'; | |
import { map, switchMap } from 'rxjs/operators'; | |
import { doLogin, setLoginStateSuccess, setErrorMessage } from './login.action'; | |
import { LoginService } from '../../services/login/login.service'; | |
@Injectable() | |
export class LoginEffects { | |
setLoginStateSuccess$ = createEffect(() => |