随笔分类 - Unit Testing
摘要:Sync api: getBy* queryBy* Async api: findBy* For sync api, when to use which? queryBy*: when the element is not always shown on screen getBy*: when th
阅读全文
摘要:Code: import type { paths } from "@octokit/openapi-types"; type OrgRepoResponse = paths["/repos/{owner}/{repo}"]["get"]["responses"]["200"]["content"]
阅读全文
摘要:Code: config.go package projector import ( "fmt" "os" "path" ) type Operation = int const ( Print Operation = iota Add Remove ) type Config struct { A
阅读全文
摘要:struct Rectangle { width: i32, height: i32 } impl Rectangle { // Only change the test functions themselves pub fn new(width: i32, height: i32) -> Self
阅读全文
摘要:pub fn is_even(num: i32) -> bool { num % 2 == 0 } /* This attribute indicates that the following module is a conditional compilation module that shoul
阅读全文
摘要:Vanilla Go includes Testing A test is a file with suffix_test.go You define functions with prefix Test and with an special signature receiving a *test
阅读全文
摘要:import { afterEach, test, expect, vi, beforeEach } from 'vitest'; import { render } from 'test/utilities'; import TimeZone from '.'; beforeEach(() =>
阅读全文
摘要:1. Globally import In vitest, you need to do import { it, expect, test } from 'vitest'; In every test files, If you don't want to do it you can set co
阅读全文
摘要:1. TSD: https://github.com/SamVerschueren/tsd import {expectType} from 'tsd'; import concat from '.'; expectType<string>(concat('foo', 'bar')); expect
阅读全文
摘要:import { WatermarkOverlay } from '../watermark-overlay' describe('WatermarkOverlay', () => { let cmp: HTMLElement let fixture: HTMLElement let shadow:
阅读全文
摘要:import { test } from '@playwright/test'; test.beforeEach(async ({ page }) => { await page.goto('http://localhost:3000'); }); test('selectors', async (
阅读全文
摘要:jest.mock('./filename', () => { const originalModule = jest.requireActual('./filename') return { ...originalModule, fnA: jest.fn(), fnB: (b: boolean):
阅读全文
摘要:Co-Variance: declare let b: string declare let c: string | number c = b // ✅ // string is a sub-type of string | number // all elements of string appe
阅读全文
摘要:Example: expect(contextSpy.sendEncodedMessage).toHaveBeenCalledWith( expect.objectContaining({ correlationId: expect.objectContaining({ operationId: '
阅读全文
摘要:https://github.com/kentcdodds/react-testing-library-course/commit/1148e920b8d055d9ca9ef1c372e233d2e950ff1f User-event: https://testing-library.com/doc
阅读全文
摘要:Must have Configure Jest to Run Setup for All Tests with Jest setupFilesAfterEnv We want to include '@testing-library/jest-dom'so that we can have suc
阅读全文
摘要:const { of } = require("rxjs"); const { mergeMap, map, delay, catchError } = require("rxjs/operators"); describe("subscribe & assert testing in RxJS",
阅读全文
摘要:For example we have a search input: const input$ = fromEvent(document.getElementById("#input"), "input"); input$ .pipe( debounceTime(200), pluck("targ
阅读全文
摘要:const { TestScheduler } = require("rxjs/testing"); const { map, take, delay, mapTo, catchError } = require("rxjs/operators"); const { concat, from, of
阅读全文
摘要:describe("Marble testing in Rxjs", () => { let testScheduler; beforeEach(() => { testScheduler = new TestScheduler((actual, expected) => { expect(actu
阅读全文