Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

Replace vitest with jest #58

Draft
wants to merge 2 commits into
base: integration/v3
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'jsdom',
};
7,786 changes: 5,215 additions & 2,571 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"types": "dist/mjs/index.d.ts",
"scripts": {
"start": "npx vite serve",
"test": "vitest run",
"test": "jest",
"ci": "npm run test && npm run build",
"build": "npm run build:cjs && npm run build:mjs",
"build:mjs": "tsc --project tsconfig.mjs.json && cp res/package.mjs.json dist/mjs/package.json",
Expand All @@ -32,7 +32,9 @@
},
"homepage": "https://github.com/ably-labs/react-hooks#readme",
"devDependencies": {
"@testing-library/react": "^13.3.0",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@types/jest": "^29.5.3",
"@typescript-eslint/eslint-plugin": "^6.1.0",
"@typescript-eslint/parser": "^6.1.0",
"@vitejs/plugin-react": "^1.3.2",
Expand All @@ -41,12 +43,15 @@
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"jest": "^29.6.1",
"jest-environment-jsdom": "^29.6.1",
"jsdom": "^20.0.0",
"prettier": "^3.0.0",
"react": ">=18.1.0",
"react-dom": ">=18.1.0",
"ts-jest": "^29.1.1",
"typescript": ">=4.4.4",
"vitest": "^0.18.0"
"vite": "^4.4.7"
},
"dependencies": {
"ably": "^1.2.27",
Expand Down
1 change: 0 additions & 1 deletion src/hooks/useChannel.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { it, beforeEach, describe, expect } from 'vitest';
import { useChannel } from './useChannel';
import { useState } from 'react';
import { render, screen } from '@testing-library/react';
Expand Down
1 change: 0 additions & 1 deletion src/hooks/usePresence.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { it, beforeEach, describe, expect } from 'vitest';
import { usePresence } from './usePresence';
import { render, screen, act } from '@testing-library/react';
import { FakeAblySdk, FakeAblyChannels } from '../fakes/ably';
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/usePresence.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Types } from 'ably';
import { useCallback, useEffect, useState } from 'react';
import { ChannelParameters } from '../AblyReactHooks.js';
import { useAbly } from './useAbly.js';
import { ChannelParameters } from '../AblyReactHooks';
import { useAbly } from './useAbly';

export type PresenceDataAndPresenceUpdateFunction<T> = [
presenceData: PresenceMessage<T>[],
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "./tsconfig.base.json",
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "CommonJS",
"outDir": "dist/cjs"
Expand Down
3 changes: 1 addition & 2 deletions tsconfig.base.json → tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"skipLibCheck": true,
"allowJs": true,
"jsx": "react-jsx",
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"types": ["vitest/globals"]
"lib": ["DOM", "DOM.Iterable", "ESNext"]
}
}
2 changes: 1 addition & 1 deletion tsconfig.mjs.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "./tsconfig.base.json",
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "ES6",
"outDir": "dist/mjs"
Expand Down
6 changes: 1 addition & 5 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig } from 'vitest/config';
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

export default defineConfig({
Expand All @@ -9,8 +9,4 @@ export default defineConfig({
host: true,
},
plugins: [react()],
test: {
globals: true,
environment: 'jsdom',
},
});
11 changes: 0 additions & 11 deletions vitest.config.ts

This file was deleted.