![]() ![]() In our first example, the library exports is a single default function. All of those choices affect how the package needs to be mocked in the tests of our application code.īelow, we'll look at some tiny examples to highlight how different exports change our mock strategy. When publishing a package, the maintainer makes decisions such as choosing default or named exports and whether to export a vanilla function, an object, or a function that returns an object of other functions. ES6 Exportsīefore we worry about our mock's behavior, it's important to understand how the package we're using is exported. It's a React app with Jest as the test runner and uses React Testing Library to test the component DOM (this is the default configuration with Create React App).ĭespite being built with React, the mocking examples should be easily portable to any framework. The sample application shows you a random cute image of an animal every 3 seconds. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |