Skip to content

Move from Jest to node:test #94

@compulim

Description

@compulim

Version

Latest development (@main)

Module resolution

Others or unrelated

Bundler

Others or unrelated

Environment

Others or unrelated

Test case

Coding sandbox URL

No response

Console errors

Screenshots

No response

Additional context

Move from Jest to Node.js test runner to speed up test.

The test code under packages/react-chain-of-responsibility should be updated.

Here is the diff.

- /** @jest-environment jsdom */
- /// <reference types="@types/jest" />
  
  import { render } from '@testing-library/react';
+ import { test } from 'node:test';
  import React, { Fragment } from 'react';
  import { withProps, wrapWith } from 'react-wrap-with';
  
  import createChainOfResponsibility from '../../createChainOfResponsibility';
  
  type Props = { children?: never };
  
  test('middleware return a component with content of init should render', () => {
    // GIVEN: A middleware return component with content of init object.
    const { Provider, Proxy } = createChainOfResponsibility<void, Props, string>();
  
    // WHEN: Render <Provider> with the init of "Hello, World!".
    const App = wrapWith(
      withProps(Provider, {
        init: 'Hello, World!',
        middleware: [init => () => () => () => <Fragment>{init}</Fragment>]
      })
    )(Proxy);
  
    const result = render(<App request={undefined} />);
  
    // THEN: It should render "Hello, World!".
    expect(result.container).toHaveProperty('textContent', 'Hello, World!');
  });

In package.json, also modify the test to run node --test ${CI:---watch} **/*.{spec,test}.{[jt]s,c[jt]s,m[jt]s} instead of jest.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions