Make Vitest helpers global
This commit is contained in:
@@ -6,4 +6,8 @@ import { css } from 'css-configuration';
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
css,
|
||||
test: {
|
||||
environment: 'happy-dom',
|
||||
globals: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
import { mergeConfig } from 'vitest/config';
|
||||
import config from './vite.config';
|
||||
|
||||
export default mergeConfig(config, {
|
||||
test: {
|
||||
environment: 'happy-dom',
|
||||
},
|
||||
});
|
||||
@@ -1,4 +1,3 @@
|
||||
import { it, expect, describe } from 'vitest';
|
||||
import { createButton } from './button.js';
|
||||
|
||||
describe('createButton', () => {
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { it, expect } from 'vitest';
|
||||
|
||||
it('should properly assign to localStorage', () => {
|
||||
const key = 'secret';
|
||||
const message = "It's a secret to everybody.";
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { describe, expect, it, beforeEach, vi, afterEach } from 'vitest';
|
||||
import { screen } from '@testing-library/dom';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { createSecretInput } from './secret-input.js';
|
||||
|
||||
@@ -3,5 +3,6 @@ import { defineConfig } from 'vitest/config';
|
||||
export default defineConfig({
|
||||
test: {
|
||||
environment: 'happy-dom',
|
||||
globals: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -4,4 +4,8 @@ import { css } from 'css-configuration';
|
||||
export default defineConfig({
|
||||
assetsInclude: ['**/*.html'],
|
||||
css,
|
||||
test: {
|
||||
environment: 'happy-dom',
|
||||
globals: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
import { mergeConfig } from 'vitest/config';
|
||||
import config from './vite.config';
|
||||
|
||||
export default mergeConfig(config, {
|
||||
test: {
|
||||
environment: 'happy-dom',
|
||||
},
|
||||
});
|
||||
@@ -1,5 +1,6 @@
|
||||
export default {
|
||||
test: {
|
||||
environment: 'node',
|
||||
globals: true,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
export default {
|
||||
test: {
|
||||
environment: 'node',
|
||||
globals: true,
|
||||
},
|
||||
};
|
||||
|
||||
8
examples/logjam/vitest.config.js
Normal file
8
examples/logjam/vitest.config.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import { defineConfig } from 'vitest/config';
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
environment: 'node',
|
||||
globals: true,
|
||||
},
|
||||
});
|
||||
11
examples/task-list/src/actions.test.js
Normal file
11
examples/task-list/src/actions.test.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import { setTasks } from './actions';
|
||||
|
||||
describe('setTasks', () => {
|
||||
it('creates a set-tasks action', () => {
|
||||
const tasks = [{ id: '1', text: 'Task 1', completed: false }];
|
||||
expect(setTasks(tasks)).toEqual({
|
||||
type: 'set-tasks',
|
||||
payload: tasks,
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -15,7 +15,7 @@ export const CreateTask = ({ onSubmit }) => {
|
||||
>
|
||||
<div>
|
||||
<label htmlFor="new-task-title" className="sr-only">
|
||||
Title
|
||||
Create Task
|
||||
</label>
|
||||
<div className="flex flex-row">
|
||||
<input
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { memo } from 'react';
|
||||
import { ChevronRightCircle } from 'lucide-react';
|
||||
import { DateTime } from './date-time';
|
||||
|
||||
export const Task = memo(({ task, updateTask, removeTask }) => {
|
||||
@@ -7,7 +6,7 @@ export const Task = memo(({ task, updateTask, removeTask }) => {
|
||||
<li className="block space-y-2 border-x border-t border-slate-300 bg-white p-4 first:rounded-t-md last:rounded-b-md last:border-b dark:border-slate-700">
|
||||
<header className="flex flex-row items-center gap-4">
|
||||
<label htmlFor={`toggle-${task.id}`} className="sr-only">
|
||||
Mark Task as {task.completed ? 'Incomplete' : 'Complete'}
|
||||
Completed?
|
||||
</label>
|
||||
<input
|
||||
id={`toggle-${task.id}`}
|
||||
@@ -20,6 +19,7 @@ export const Task = memo(({ task, updateTask, removeTask }) => {
|
||||
<button
|
||||
className="button-small button-destructive button-ghost"
|
||||
onClick={() => removeTask(task.id)}
|
||||
aria-label='Remove Task'
|
||||
>
|
||||
❌
|
||||
</button>
|
||||
|
||||
@@ -16,4 +16,9 @@ export default defineConfig({
|
||||
},
|
||||
},
|
||||
},
|
||||
test: {
|
||||
environment: 'happy-dom',
|
||||
globals: true,
|
||||
setupFiles: ['@testing-library/jest-dom/vitest'],
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
import { mergeConfig } from 'vite';
|
||||
import config from './vite.config';
|
||||
|
||||
export default mergeConfig(config, {
|
||||
test: {
|
||||
environment: 'happy-dom',
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
export * from './string-to-number';
|
||||
|
||||
8
examples/utility-belt/vitest.config.js
Normal file
8
examples/utility-belt/vitest.config.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import { defineConfig } from 'vitest/config';
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
environment: 'node',
|
||||
globals: true,
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user