Loading...
「ツール」は右上に移動しました。
利用したサーバー: wtserver1
1781いいね 77,652 views回再生

Mocking Asynchronous Functions with Jest

Mocking is a fundamental skill in testing. It allows you to avoid testing parts of your code that are outside your control, or to get reliable return values from said code.

00:00 - What we'll cover
01:00 - Reviewing the project setup
03:02 - Creating the test
06:24 - Adding async await to pass test
07:17 - Why mock an api request for unit tests
08:32 - Adding jest mock for axios
14:06 - Check if mock function has been called
15:31 - Shorthand for mocking resolved promise value
16:23 - Gotcha for mock state, and how to clear it each test
18:24 - Alternate way of mocking within a test file
20:50 - Wrap-up

Repository for code example:
https://github.com/Jimmydalecleveland...

Blog Post:
https://blog.jimmydc.com/mock-asynchr...

Swapi Dev:
https://swapi.dev/

Follow Jimmy Cleveland's doings:
twitter:   / jimmydcleveland  
blog: https://blog.jimmydc.com/

#jest #mock #async

コメント