Onepager: testify test suite

stretchr: testify… … is used in many projects, minimal for assertions, but also it is really useful for mocks and testsuites https://github.com/stretchr/testify Even when the README contains all information, this is my one-pager to quickstart start a new testfile type ToTestTestSuite struct { suite.Suite } func (s *ToTestTestSuite) SetupTest() {} func (s *ToTestTestSuite) AfterTest() {} func (s *ToTestTestSuite) BeforeTest(suiteName, testName string) {} func (s *ToTestTestSuite) TearDownTest() {} type DependencyMock struct { mock....

jest testing tricks with react and mobx

First of all, i use a lot of jest with @testing-library/react. I think everyone heard about it and is already using it, if not, please give it a try :) To get everything up and testing, we need to glue everything together with the jest config and the global test setup setup hints // jest.config.js module.exports = { preset: 'ts-jest', testEnvironment: 'node', setupFilesAfterEnv: ['./globalTestSetup.js'] }; // globalTestSetup.js require('jest-styled-components') require('@testing-library/jest-dom/extend-expect') require('mobx-react-lite/batchingForReactDom') mocking a mobx model from useContext In my current default setup, i’m using mob-react-lite and the useContext hook to access the data store....

Last posts

Tags