mirror of
https://github.com/portainer/portainer.git
synced 2025-08-02 20:35:25 +02:00
feat(ci): replace jest with vitest [EE-6504] (#10997)
Some checks are pending
ci / build_images (map[arch:amd64 platform:linux]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
ci / build_images (map[arch:arm64 platform:linux]) (push) Waiting to run
ci / build_manifests (push) Blocked by required conditions
/ triage (push) Waiting to run
Lint / Run linters (push) Waiting to run
Test / test-client (push) Waiting to run
Test / test-server (map[arch:amd64 platform:linux]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
Test / test-server (map[arch:arm64 platform:linux]) (push) Waiting to run
Some checks are pending
ci / build_images (map[arch:amd64 platform:linux]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
ci / build_images (map[arch:arm64 platform:linux]) (push) Waiting to run
ci / build_manifests (push) Blocked by required conditions
/ triage (push) Waiting to run
Lint / Run linters (push) Waiting to run
Test / test-client (push) Waiting to run
Test / test-server (map[arch:amd64 platform:linux]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
Test / test-server (map[arch:arm64 platform:linux]) (push) Waiting to run
This commit is contained in:
parent
4a19871fcc
commit
69c06bc756
34 changed files with 1137 additions and 1680 deletions
|
@ -44,7 +44,7 @@ test('should render with the initial value selected and call onChange when click
|
|||
},
|
||||
];
|
||||
|
||||
const onChange = jest.fn();
|
||||
const onChange = vi.fn();
|
||||
const { getByLabelText } = renderDefault({
|
||||
options,
|
||||
onChange,
|
||||
|
|
|
@ -37,7 +37,7 @@ test('should call onSelect when clicked with id', async () => {
|
|||
{ children: 'Content 2', id: 'option2', label: 'Option 2' },
|
||||
];
|
||||
|
||||
const onSelect = jest.fn();
|
||||
const onSelect = vi.fn();
|
||||
|
||||
const { findByText } = renderComponent(options, options[1].id, onSelect);
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@ import { HeaderContainer } from './HeaderContainer';
|
|||
import { HeaderTitle } from './HeaderTitle';
|
||||
|
||||
test('should not render without a wrapping HeaderContainer', async () => {
|
||||
const consoleErrorFn = jest
|
||||
const consoleErrorFn = vi
|
||||
.spyOn(console, 'error')
|
||||
.mockImplementation(() => jest.fn());
|
||||
.mockImplementation(() => vi.fn());
|
||||
|
||||
const title = 'title';
|
||||
function renderComponent() {
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`should not render without a wrapping HeaderContainer 1`] = `"Should be nested inside a HeaderContainer component"`;
|
||||
exports[`should not render without a wrapping HeaderContainer 1`] = `[Error: Should be nested inside a HeaderContainer component]`;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { http, HttpResponse } from 'msw';
|
||||
import { Mock } from 'vitest';
|
||||
|
||||
import { Tag, TagId } from '@/portainer/tags/types';
|
||||
import { renderWithQueryClient } from '@/react-tools/test-utils';
|
||||
|
@ -43,11 +44,11 @@ async function renderComponent(
|
|||
{
|
||||
value = [],
|
||||
allowCreate = false,
|
||||
onChange = jest.fn(),
|
||||
onChange = vi.fn(),
|
||||
}: {
|
||||
value?: TagId[];
|
||||
allowCreate?: boolean;
|
||||
onChange?: jest.Mock;
|
||||
onChange?: Mock;
|
||||
} = {},
|
||||
tags: Tag[] = []
|
||||
) {
|
||||
|
|
|
@ -26,7 +26,7 @@ function renderDefault({
|
|||
|
||||
test('should display a Button component and allow onClick', async () => {
|
||||
const children = 'test label';
|
||||
const onClick = jest.fn();
|
||||
const onClick = vi.fn();
|
||||
const { findByText } = renderDefault({ children, onClick });
|
||||
|
||||
const buttonLabel = await findByText(children);
|
||||
|
|
|
@ -15,7 +15,7 @@ test('should display a CopyButton with children', async () => {
|
|||
test('CopyButton should copy text to clipboard', async () => {
|
||||
// override navigator.clipboard.writeText (to test copy to clipboard functionality)
|
||||
let clipboardText = '';
|
||||
const writeText = jest.fn((text) => {
|
||||
const writeText = vi.fn((text) => {
|
||||
clipboardText = text;
|
||||
});
|
||||
Object.assign(navigator, {
|
||||
|
|
|
@ -3,7 +3,7 @@ import { fireEvent, render } from '@/react-tools/test-utils';
|
|||
import { FileUploadField } from './FileUploadField';
|
||||
|
||||
test('render should make the file button clickable and fire onChange event after click', async () => {
|
||||
const onClick = jest.fn();
|
||||
const onClick = vi.fn();
|
||||
const { findByText, findByLabelText } = render(
|
||||
<FileUploadField
|
||||
title="test button"
|
||||
|
|
|
@ -3,7 +3,7 @@ import { render } from '@/react-tools/test-utils';
|
|||
import { FileUploadForm } from './FileUploadForm';
|
||||
|
||||
test('render should include description', async () => {
|
||||
const onClick = jest.fn();
|
||||
const onClick = vi.fn();
|
||||
const { findByText } = render(
|
||||
<FileUploadForm
|
||||
title="test button"
|
||||
|
|
|
@ -6,7 +6,7 @@ function renderDefault({
|
|||
name = 'default name',
|
||||
checked = false,
|
||||
label = 'label',
|
||||
onChange = jest.fn(),
|
||||
onChange = vi.fn(),
|
||||
index,
|
||||
}: Partial<Props> = {}) {
|
||||
return render(
|
||||
|
@ -28,7 +28,7 @@ test('should display a Switch component', async () => {
|
|||
});
|
||||
|
||||
test('clicking should emit on-change with the opposite value', async () => {
|
||||
const onChange = jest.fn();
|
||||
const onChange = vi.fn();
|
||||
const checked = true;
|
||||
const { findByRole } = renderDefault({ onChange, checked });
|
||||
|
||||
|
@ -39,7 +39,7 @@ test('clicking should emit on-change with the opposite value', async () => {
|
|||
});
|
||||
|
||||
test('clicking should emit on-change with the opposite value and index', async () => {
|
||||
const onChange = jest.fn();
|
||||
const onChange = vi.fn();
|
||||
const checked = true;
|
||||
const index = 3;
|
||||
const { findByRole } = renderDefault({ onChange, checked, index });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue