Skip to content

Commit

Permalink
Upgrade jest, use swc, switch to community package for playwright int…
Browse files Browse the repository at this point in the history
…egration
  • Loading branch information
airhorns committed Jul 26, 2022
1 parent 85af14f commit e252778
Show file tree
Hide file tree
Showing 14 changed files with 1,361 additions and 1,263 deletions.
18 changes: 18 additions & 0 deletions .swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"env": {
"targets": {
"node": 16
}
},
"jsc": {
"parser": {
"syntax": "typescript",
"decorators": true,
"dynamicImport": true
},
"target": "es2020"
},
"module": {
"type": "commonjs"
}
}
6 changes: 1 addition & 5 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
module.exports = {
preset: 'ts-jest',
testTimeout: process.env.CI ? 30000 : 10000,
globalSetup: './scripts/jestGlobalSetup.js',
globalTeardown: './scripts/jestGlobalTeardown.js',
testEnvironment: './scripts/jestEnv.js',
projects: ['<rootDir>/packages/fastify-renderer', '<rootDir>/packages/test-apps/simple-react'],
}
6 changes: 4 additions & 2 deletions packages/fastify-renderer/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ module.exports = {
// notifyMode: "failure-change",

// A preset that is used as a base for Jest's configuration
preset: 'ts-jest',
// preset: 'ts-jest',

// Run tests from one or more projects
// projects: undefined,
Expand Down Expand Up @@ -172,7 +172,9 @@ module.exports = {
// timers: "real",

// A map from regular expressions to paths to transformers
// transform: undefined,
transform: {
'^.+\\.(t|j)sx?$': '@swc/jest',
},

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
Expand Down
6 changes: 4 additions & 2 deletions packages/fastify-renderer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@
"react-dom": "experimental"
},
"devDependencies": {
"@swc/core": "^1.2.218",
"@swc/jest": "^0.2.22",
"@types/connect": "^3.4.35",
"@types/jest": "^26.0.24",
"@types/node": "^14.17.20",
Expand All @@ -93,15 +95,15 @@
"eslint-plugin-react-hooks": "^4.6.0",
"fastify": "^3.29.0",
"gitpkg": "^1.0.0-beta.2",
"jest": "^27.5.1",
"jest": "^28.1.3",
"jest-playwright-preset": "^2.0.0",
"npm-run-all": "^4.1.5",
"pino-pretty": "^4.8.0",
"prettier": "^2.7.1",
"prettier-plugin-organize-imports": "^2.3.4",
"react": "0.0.0-experimental-4ead6b530",
"react-dom": "0.0.0-experimental-4ead6b530",
"rimraf": "^3.0.2",
"ts-jest": "^27.1.4",
"typescript": "^4.7.4"
},
"files": [
Expand Down
4 changes: 0 additions & 4 deletions packages/fastify-renderer/test/esm/default-esm-export.mjs

This file was deleted.

29 changes: 0 additions & 29 deletions packages/fastify-renderer/test/esm/esm.test.ts

This file was deleted.

4 changes: 0 additions & 4 deletions packages/fastify-renderer/test/esm/named-esm-export.mjs

This file was deleted.

14 changes: 2 additions & 12 deletions packages/test-apps/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
import { FastifyInstance } from 'fastify'
import fs from 'fs-extra'
import { resolve } from 'path'
import { Browser, ConsoleMessage, Page } from 'playwright-chromium'

// injected by the test env
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace NodeJS {
interface Global {
browser?: Browser
}
}
}
import { ConsoleMessage, Page } from 'playwright-chromium'

export function slash(p: string): string {
return p.replace(/\\/g, '/')
Expand Down Expand Up @@ -72,7 +62,7 @@ afterEach(async () => {

/** Create a new playwright page for testing against */
export const newTestPage = async (): Promise<Page> => {
const page: Page = await (global as any).browser.newPage()
const page: Page = await browser.newPage()
page.on('console', onConsole)
pages.push(page)

Expand Down
12 changes: 7 additions & 5 deletions packages/test-apps/simple-react/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ module.exports = {
// forceCoverageMatch: [],

// A path to a module which exports an async function that is triggered once before all test suites
// globalSetup: undefined,
// globalSetup: '../../../scripts/jestGlobalSetup.js',

// A path to a module which exports an async function that is triggered once after all test suites
// globalTeardown: undefined,
// globalTeardown: '../../../scripts/jestGlobalTeardown.js',

// A set of global variables that need to be available in all test environments
// globals: {},
Expand Down Expand Up @@ -93,7 +93,7 @@ module.exports = {
// notifyMode: "failure-change",

// A preset that is used as a base for Jest's configuration
preset: 'ts-jest',
preset: 'jest-playwright-preset',

// Run tests from one or more projects
// projects: undefined,
Expand Down Expand Up @@ -137,7 +137,7 @@ module.exports = {
// snapshotSerializers: [],

// The test environment that will be used for testing
testEnvironment: 'node',
// testEnvironment: '../../../scripts/jestEnv.js',

// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},
Expand Down Expand Up @@ -172,7 +172,9 @@ module.exports = {
// timers: "real",

// A map from regular expressions to paths to transformers
// transform: undefined,
transform: {
'^.+\\.(t|j)sx?$': '@swc/jest',
},

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
Expand Down
2 changes: 1 addition & 1 deletion packages/test-apps/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"module": "commonjs",
"lib": ["ES2020", "dom"],
"sourceMap": true,
"types": ["jest", "node"]
"types": ["jest", "node", "jest-playwright-preset", "expect-playwright"]
}
}
38 changes: 0 additions & 38 deletions scripts/jestEnv.js

This file was deleted.

20 changes: 0 additions & 20 deletions scripts/jestGlobalSetup.js

This file was deleted.

3 changes: 0 additions & 3 deletions scripts/jestGlobalTeardown.js

This file was deleted.

Loading

0 comments on commit e252778

Please sign in to comment.