随笔分类 - Unit Testing
摘要:For example, we want to test against a implemataion: We want to do the test with Java Context: 1. Bring in some dependencies: in pom.xml Create a new
阅读全文
摘要:In this post, we are going to see more functionalities in Mockito. Mock a List interface: Call multi times: First call, return 10, second times return
阅读全文
摘要:Previously we have seen how to do Unit testing with Mockito; In this post, we are going to see, using annotation from Mockito to make testing easier:
阅读全文
摘要:We have the implemetion: And we want to test agaisnst it:
阅读全文
摘要:Check the get started guid https://junit.org/junit5/docs/current/user-guide/#overview-getting-help
阅读全文
摘要:For some React component testing, we have common setup in each test file: We want to setup a common place for JEST to load those scripts: Then for com
阅读全文
摘要:Thanks to react-testing-library our tests are free of implementation details, so when we refactor components to hooks we generally don't need to make
阅读全文
摘要:Sometimes when writing a unit test, you know that the module you're testing imports a module that you would like to observe, or at the very least mock
阅读全文
摘要:Run Jest Watch Mode by default locally with is-ci-cli In CI, we don’t want to start the tests in watch mode, but locally we normally want to run the t
阅读全文
摘要:HTML: Component Controller: Testing:
阅读全文
摘要:Setup an afterEach Test Hook for all tests with Jest setupTestFrameworkScriptFile With our current test situation, we have a commonality between most
阅读全文
摘要:The component test:
阅读全文
摘要:Most of time, when we want to test function call inside a promise, we can do: It is important to call 'done()', otherwise, the code won't call the pro
阅读全文
摘要:Transpile Modules with Babel in Jest Tests Jest automatically loads and applies our babel configuration. However, because our project takes advantage
阅读全文
摘要:Ensure Functions are Called Correctly with JavaScript Mocks Often when writing JavaScript tests and mocking dependencies, you’ll want to verify that t
阅读全文
摘要:The static code analysis and linting tool ESLint is the de-facto standard for linting JavaScript projects. In this lesson we’ll see how to install, ru
阅读全文
摘要:In this lesson, we’ll get the most fundamental understanding of what an automated test is in JavaScript. A test is code that throws an error when the
阅读全文
摘要:When testing functions that make HTTP requests, it's not preferable for those requests to actually run. Using the nock JavaScript library, we can mock
阅读全文
摘要:Unit testing functions that invoke callbacks can require a lot of setup code. Using sinon.spy to create a fake callback function can simplify your uni
阅读全文
摘要:Jest is a fantastic testing library, but maybe you've been putting off the switch because migrating all of your existing tests from another library se
阅读全文