2020-01-01から1年間の記事一覧
jestでテストを行う際、以下のように axios-mock-adapter を利用してPost(or put)系APIのモックを作成していました。 const uesr = {...}; const mock = new MockAdapter(axios); const path = `https://dummy.url.com/api/v1/user/${userId}`; mock.onPost(…
要素が存在しないことを確認しようとして次のようなコードを書いた。 it('check non-existence', () => { const { getByText } = render( <div>existence</div> ); const element = getByText(/non-existence/i); expect(element).toBeNull(); }); すると、以下のエラー…