随笔分类 - Unit Testing
摘要:Often, we end up creating multiple unit tests for the same unit of code to make sure it behaves as expected with varied input. This is a good practice
阅读全文
摘要:We want to make sure that when we ship new code, our users can use the application. The best way we've found to do that is to write automated tests th
阅读全文
摘要:With the right process in place, snapshot tests can be a great way to detect unintended changes in any part of your application that can be serialized
阅读全文
摘要:Mocha uses a default timeout of 2000 ms. However, if for some reason that does not work for your use case, you can increase the timeout for a particul
阅读全文
摘要:In this lesson, you will learn how to implement pytest fixtures. Many unit tests have the same resource requirements. For example, an instantiated obj
阅读全文
摘要:In this lesson, I use Enzyme and Jest's Snapshot functionality to write an integration test for a component called CounterConsumer that consumes the R
阅读全文
摘要:In this lesson, I use Enzyme and Jest to unit test a Counter Render Prop component. Writing integration tests are perfect for components that consume
阅读全文
摘要:Every Angular CLI generated project comes already with Karmapreinstalled as well a couple of executable Jasmine specs. The default test reporter is "p
阅读全文
摘要:In a proper unit test we want to isolate external dependencies as much as possible to guarantee a reliable test outcome. Http calls represent such ext
阅读全文
摘要:In this lesson you will create a new project with a virtual environment and write your first unit test with pytest. In doing so, you will learn: insta
阅读全文
摘要:Install: Basic example: Advanced example: Component:
阅读全文
摘要:Most of time, we get used to use class name as a selector in the test. But one problem for this is classname is used for styling, when we also use it
阅读全文
摘要:In certain situations, you care more about the final state of the redux store than you do about the particular stream of events coming out of an epic.
阅读全文
摘要:Often in unit tests we are focussing on the logic involved in crafting a network request, & how we respond to the result. The external service is unli
阅读全文
摘要:Epics can be unit-tested just like any other function in your application - they have a very specific set of inputs (the action$ stream) and the outpu
阅读全文
摘要:The way to test router componet needs a little bit setup, first we need to create a "router-stubs.ts". This file is a helper file. The component we wa
阅读全文
摘要:Both what "TestBed.get" & "injector" trying to do is get service for the test component. But there is some diffenece which determined when use which.
阅读全文
摘要:When you testing Component rendering, you often needs to call: For example: You can also set auto change detection: Add to providers: Tests wit auto c
阅读全文
摘要:When using Ngrx, we need to know how to test the component which has Router injected. Component: One thing we can test just for component wihtout temp
阅读全文
摘要:Here we want to test a toggle button component, when the button was click, state should change, style should change also. Toggle component: Test:
阅读全文