Tool | Pros | Cons |
---|---|---|
RITEway | - runs the fastest (basically instant after Babel compiled) - good for pure components (map props to JSX) - good for other unit tests (reducers, sag |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AxeBuilder from '@axe-core/playwright'; | |
import { faker } from '@faker-js/faker'; | |
import type { Page } from '@playwright/test'; | |
import { expect, test } from '@playwright/test'; | |
import type { Organization, UserAccount } from '@prisma/client'; | |
import { OrganizationMembershipRole } from '@prisma/client'; | |
import { | |
createPopulatedOrganization, | |
createPopulatedOrganizationInviteLink, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function memoize(fn) { | |
const cache = new Map(); | |
return function(...args) { | |
const key = args.toString(); | |
if (cache.has(key)) { | |
return cache.get(key); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { describe } from 'vitest'; | |
import { assert } from './riteway'; | |
describe('assert.only', () => { | |
assert({ | |
given: 'this is a failing test', | |
should: 'be skipped because another test is here with .only', | |
actual: true, | |
expected: false, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Pull Request | |
on: [pull_request] | |
jobs: | |
unit-and-integration: | |
strategy: | |
fail-fast: false | |
matrix: | |
command: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { describe } from 'riteway'; | |
import fn from './mock-fn.js'; | |
describe('fn - the mock function', async assert => { | |
const mockedFn = fn((a, b) => a + b); | |
assert({ | |
given: 'calling a mocked function', | |
should: 'should return the correct result', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fn(implementation = () => {}) { | |
const mockFn = (...args) => { | |
mockFn.calls.push(args); | |
return implementation(...args); | |
}; | |
mockFn.calls = []; | |
return mockFn; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from 'react'; | |
import HomePageComponent from './home-page-component.js'; | |
function HomePage() { | |
const [count, setCount] = useState(0); | |
function handleIncrementClick() { | |
setCount(c => c + 1); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { fireEvent, render } from '@testing-library/react'; | |
import { describe } from 'riteway'; | |
import HomePage from './home-page-container.js'; | |
describe('HomePage container', async assert => { | |
const { getByText, getByTestId } = render(<HomePage />); | |
fireEvent.click(getByText(/increment/i)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
const HomePage = ({ count, onIncrementClick = () => {} }) => ( | |
<main> | |
<p className="count" data-testid="count"> | |
{count} | |
</p> | |
<button className="increment-button" onClick={onIncrementClick}> | |
Increment | |
</button> |
NewerOlder