-
Notifications
You must be signed in to change notification settings - Fork 621
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
39 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
build | ||
*.cjs | ||
*.js |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
/** @type {import('jest').Config} */ | ||
const config = { | ||
export default { | ||
preset: 'ts-jest/presets/default-esm', | ||
testPathIgnorePatterns: ['<rootDir>/node_modules', '<rootDir>/build', '<rootDir>/_site', '<rootDir>/src'], | ||
coverageDirectory: './coverage/', | ||
collectCoverage: false, | ||
setupFiles: ['./test/jest.overrides.ts'], | ||
globals: { | ||
'ts-jest': { | ||
diagnostics: false, | ||
useESM: true | ||
} | ||
transform: { | ||
'^.+\\.ts$': [ | ||
'ts-jest', | ||
{ | ||
diagnostics: false, | ||
useESM: true | ||
} | ||
] | ||
} | ||
}; | ||
|
||
module.exports = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,29 @@ | ||
const {mkdir, writeFile} = require('fs').promises; | ||
const os = require('os'); | ||
const path = require('path'); | ||
const puppeteer = require('puppeteer'); | ||
const {setup: setupDevServer} = require('jest-dev-server'); | ||
const chalk = require('chalk'); | ||
import {mkdir, writeFile} from 'fs/promises'; | ||
import {tmpdir} from 'os'; | ||
import {join} from 'path'; | ||
import {launch} from 'puppeteer'; | ||
import {setup as setupDevServer} from 'jest-dev-server'; | ||
import chalk from 'chalk'; | ||
|
||
const DIR = path.join(os.tmpdir(), 'jest_puppeteer_global_setup'); | ||
const {green} = chalk; | ||
|
||
module.exports = async function () { | ||
const DIR = join(tmpdir(), 'jest_puppeteer_global_setup'); | ||
|
||
export default async function () { | ||
globalThis.servers = await setupDevServer({ | ||
command: `node ./node_modules/.bin/serve -l 8000`, | ||
launchTimeout: 50000, | ||
port: 8000 | ||
}); | ||
|
||
console.log(chalk.green('Setup Puppeteer')); | ||
console.log(green('Setup Puppeteer')); | ||
|
||
const browser = await puppeteer.launch(); | ||
const browser = await launch(); | ||
// store the browser instance so we can teardown it later | ||
// this global is only available in the teardown but not in TestEnvironments | ||
globalThis.__BROWSER_GLOBAL__ = browser; | ||
|
||
// use the file system to expose the wsEndpoint for TestEnvironments | ||
await mkdir(DIR, {recursive: true}); | ||
await writeFile(path.join(DIR, 'wsEndpoint'), browser.wsEndpoint()); | ||
}; | ||
await writeFile(join(DIR, 'wsEndpoint'), browser.wsEndpoint()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
const fs = require('fs').promises; | ||
const os = require('os'); | ||
const path = require('path'); | ||
const {teardown: teardownDevServer} = require('jest-dev-server'); | ||
import {rm} from 'fs/promises'; | ||
import os from 'os'; | ||
import path from 'path'; | ||
import {teardown as teardownDevServer} from 'jest-dev-server'; | ||
|
||
const DIR = path.join(os.tmpdir(), 'jest_puppeteer_global_setup'); | ||
|
||
module.exports = async function () { | ||
export default async function () { | ||
await teardownDevServer(globalThis.servers); | ||
|
||
// close the browser instance | ||
await globalThis.__BROWSER_GLOBAL__.close(); | ||
|
||
// clean-up the wsEndpoint file | ||
await fs.rm(DIR, {recursive: true, force: true}); | ||
}; | ||
await rm(DIR, {recursive: true, force: true}); | ||
} |