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

feat: jest with esm support #3911

Merged
merged 35 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
f78cb6f
feat: jest with esm support
sublimator Jun 27, 2023
cd7c2f3
feat: jest with esm support
sublimator Jun 27, 2023
23148aa
feat: jest with esm support
sublimator Jun 27, 2023
0b4108f
feat: jest with esm support
sublimator Jun 27, 2023
6c00ff4
feat: jest with esm support
sublimator Jun 27, 2023
f671079
feat: jest with esm support
sublimator Jun 27, 2023
a07f8d3
feat: jest with esm support
sublimator Jun 27, 2023
db79038
feat: jest with esm support
sublimator Jun 27, 2023
fccd0c9
feat: jest with esm support
sublimator Jun 27, 2023
a862a65
feat: jest with esm support
sublimator Jun 27, 2023
becb704
feat: jest with esm support
sublimator Jun 27, 2023
8344455
feat: jest with esm support
sublimator Jun 27, 2023
999e5e5
feat: jest with esm support
sublimator Jun 27, 2023
f5f2c60
feat: jest with esm support
sublimator Jun 27, 2023
dd8b5d2
feat: jest with esm support
sublimator Jun 27, 2023
a7c864e
feat: jest with esm support
sublimator Jun 27, 2023
7d18b6c
feat: jest with esm support
sublimator Jun 27, 2023
c14ce76
feat: jest with esm support
sublimator Jun 28, 2023
8032554
feat: use root version of devDependencies
sublimator Jun 28, 2023
9b5f78b
fix(package.json): add lint-staged support for .mts files
sublimator Jun 28, 2023
dccbb2f
feat: jest with esm support
sublimator Jun 28, 2023
1fe3f9e
feat: jest with esm support
sublimator Jun 28, 2023
6c67a81
feat: jest with esm support
sublimator Jun 28, 2023
5efdc97
feat: jest with esm support
sublimator Jun 28, 2023
3cc284a
feat: jest with esm support
sublimator Jun 28, 2023
d4dad27
feat: jest with esm support
sublimator Jun 28, 2023
4d8eba8
feat: jest with esm support
sublimator Jun 28, 2023
1061f8a
feat: jest with esm support
sublimator Jun 28, 2023
120b21b
feat: use @jest/globals
sublimator Jun 28, 2023
dbb94fd
feat: use @jest/globals
sublimator Jun 28, 2023
c8a10cf
feat: use @jest/globals
sublimator Jun 28, 2023
c5fa72a
feat: jest with esm support
sublimator Jun 28, 2023
8c67176
feat: set repository.packages
sublimator Jun 29, 2023
34858f2
feat: add extra test env globals
sublimator Jun 29, 2023
4392714
feat: move config to root
sublimator Jun 29, 2023
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
4 changes: 4 additions & 0 deletions commands/jest/jsdomWithFetchEnv.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { TestEnvironment } = require('jest-environment-jsdom')
const crypto = require('crypto')

/**
* Jest creates a new VM context for each test and doesn't add in the node
Expand All @@ -13,6 +14,9 @@ class CustomizedTestEnvironment extends TestEnvironment {
async setup() {
await super.setup()
this.global.fetch = globalThis.fetch
this.global.TextDecoder = globalThis.TextDecoder
this.global.TextEncoder = globalThis.TextEncoder
this.global.crypto.subtle = require('crypto').webcrypto.subtle
}
}

Expand Down
2 changes: 1 addition & 1 deletion jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const moduleNameMapper = MAP_PATHS_TO_MODULES ? pathsToModuleNames : undefined

let config = {
preset: 'ts-jest',
projects: ['<rootDir>/packages{-archived,}/*/jest.config.cjs'],
projects: ['<rootDir>/packages{-archived,}/*/jest.config.{cjs,mjs}'],
testEnvironment: `${__dirname}/commands/jest/jsdomWithFetchEnv.js`,
rootDir: '.',
moduleNameMapper,
Expand Down
56 changes: 56 additions & 0 deletions jest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { existsSync, readFileSync } from 'node:fs'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'

import { parse as parseJSON } from 'JSON2016/JSON2016.js'
import { pathsToModuleNameMapper } from 'ts-jest'

const SKIP_LIB_CHECK = Boolean(
process.env.TS_JEST_COMPILER_OPTIONS_SKIP_LIB_CHECK
)
const ISOLATED_MODULES = Boolean(process.env.TS_JEST_ISOLATED_MODULES)
const MAP_PATHS_TO_MODULES =
process.env.TS_JEST_MAP_PATHS_TO_MODULES !== 'false'

const ROOT = dirname(fileURLToPath(import.meta.url))
const tsConfig = resolve(ROOT, 'tsconfig.json')
const { compilerOptions } = parseJSON(
readFileSync(tsConfig, { encoding: 'utf8' })
)
const pathsToModuleNames = pathsToModuleNameMapper(compilerOptions.paths, {
prefix: `${ROOT}/`
})

const moduleNameMapper = MAP_PATHS_TO_MODULES ? pathsToModuleNames : undefined

let config = {
preset: 'ts-jest',
projects: ['<rootDir>/packages{-archived,}/*/jest.config.{mjs,js}'],
testEnvironment: `${ROOT}/commands/jest/jsdomWithFetchEnv.js`,
rootDir: '.',
moduleNameMapper,
resolver: `${ROOT}/commands/jest/resolver.js`,
moduleFileExtensions: ['js', 'mts', 'ts', 'tsx', 'jsx', 'json'],
transform: {
'^.+\\.(t|j)sx?$': ['@swc/jest']
},
setupFiles: [ROOT + '/commands/jest/loadReflection.js'],
globals: {
'ts-jest': {
compilerOptions: {
// Speed up typechecks
skipLibCheck: SKIP_LIB_CHECK
},
isolatedModules: ISOLATED_MODULES,
diagnostics: false
}
}
}

const localConfPath = `${ROOT}/jest.config.local.cjs`
sublimator marked this conversation as resolved.
Show resolved Hide resolved
const localConf = existsSync(localConfPath) ? await import(localConfPath) : {}
if (typeof localConf === 'function') {
config = localConf(config)
}

export default config
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@
},
"scripts": {
"lint": "eslint --cache --cache-location node_modules/.cache/eslint",
"test": "jest --passWithNoTests",
"test:e2e": "pnpm run test --config jest-e2e.config.cjs",
"test:e2e:coverage": "pnpm test:coverage --config jest-e2e.config.cjs",
"jest": "NODE_OPTIONS=--experimental-vm-modules jest --passWithNoTests",
"test": "pnpm jest --config jest.config.mjs",
"test:coverage": "pnpm run test --coverage --verbose",
"prettier": "prettier --write 'packages{-archived,}/*/*.{html,js,ts,tsx,jsx,md}' 'packages{-archived,}/*/{src,test}/**/*.{ts,tsx,js,jsx,html,md}'",
"test:e2e": "pnpm jest --config jest-e2e.config.cjs",
"test:e2e:coverage": "pnpm --coverage --verbose --config jest-e2e.config.cjs",
"prettier": "prettier --write 'packages{-archived,}/*/*.{html,js,ts,mts,tsx,jsx,md}' 'packages{-archived,}/*/{src,test}/**/*.{mts,ts,tsx,js,jsx,html,md}'",
"format": "pnpm prettier && LINT_FIX=1 pnpm lint:all --fix --quiet",
"upkeep": "ts-node --swc packages/coil-monorepo-upkeep/src/bin/upkeep.ts",
"upkeep:new-package": "ts-node --swc packages/coil-monorepo-upkeep/new-package.ts",
"clean:build": "rimraf packages{-archived,}/*/build",
"build:ts": "tsc --build tsconfig.references.json",
"build:ci": "ts-node --swc packages/niq-ci/src/generate/generateGAWorkflow.ts",
"build:ts:verbose": "pnpm build:ts --verbose",
"lint:all": "pnpm lint 'packages{-archived,}/*/{src,test}/**/*.ts*'",
"lint:all": "pnpm lint 'packages{-archived,}/*/{src,test}/**/*.{mts,ts}*'",
"lint:staged": "lint-staged --shell",
"postinstall": "husky install"
},
Expand Down
12 changes: 12 additions & 0 deletions packages/coil-anonymous-tokens/jest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// FROM UPKEEP TEMPLATE
import { createRequire } from 'node:module'

const require = createRequire(import.meta.url)
const config = require('./jest.config.cjs')

config.extensionsToTreatAsEsm = ['.mts']
config.moduleFileExtensions.push('mts')
config.testMatch = config.testMatch.concat(
config.testMatch.map( tm => tm.replace('.ts?', '.mts?')))

export default config
12 changes: 6 additions & 6 deletions packages/coil-anonymous-tokens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
"clean:build": "rimraf build",
"format": "pnpm prettier && LINT_FIX=1 pnpm lint:all --fix --quiet",
"lint": "eslint --cache --cache-location ../../node_modules/.cache/eslint",
"lint:all": "pnpm lint 'src/**/*.{ts,tsx}' 'test/**/*.{ts,tsx}'",
"lint:all": "pnpm lint 'src/**/*.{mts,ts,tsx}' 'test/**/*.{mts,ts,tsx}'",
"precommit": "echo lint-staged runs from root",
"prettier": "prettier --write '*.{ts,tsx,js,html,jsx,md}' '{src,test}/**/*.{ts,tsx,js,html,jsx,md}'",
"test": "PROJECT_JEST=1 jest --passWithNoTests",
"test:coverage": "pnpm run test --verbose --coverage",
"test:e2e": "pnpm run test --config jest-e2e.config.cjs",
"test:e2e:coverage": "pnpm test:coverage --config jest-e2e.config.cjs",
"prettier": "prettier --write '*.{mts,ts,tsx,js,html,jsx,md}' '{src,test}/**/*.{mts,ts,tsx,js,html,jsx,md}'",
"test": "NODE_OPTIONS=--experimental-vm-modules PROJECT_JEST=1 jest --passWithNoTests --config jest.config.cjs",
"test:coverage": "NODE_OPTIONS=--experimental-vm-modules PROJECT_JEST=1 jest --passWithNoTests --verbose --coverage --config jest.config.cjs",
"test:e2e": "NODE_OPTIONS=--experimental-vm-modules PROJECT_JEST=1 jest --passWithNoTests --config jest-e2e.config.cjs",
"test:e2e:coverage": "NODE_OPTIONS=--experimental-vm-modules PROJECT_JEST=1 jest --passWithNoTests --verbose --coverage --config jest-e2e.config.cjs",
"tsnodeenv": "NODE_OPTIONS=\"${NODE_OPTIONS:-} --require tsconfig-paths/register\" TS_NODE_PROJECT=\"../../tsconfig.cjs.json\"",
"upkeep": "cd ../.. && pnpm upkeep"
},
Expand Down
12 changes: 12 additions & 0 deletions packages/coil-client/jest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// FROM UPKEEP TEMPLATE
import { createRequire } from 'node:module'

const require = createRequire(import.meta.url)
const config = require('./jest.config.cjs')

config.extensionsToTreatAsEsm = ['.mts']
config.moduleFileExtensions.push('mts')
config.testMatch = config.testMatch.concat(
config.testMatch.map( tm => tm.replace('.ts?', '.mts?')))

export default config
12 changes: 6 additions & 6 deletions packages/coil-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
"clean:build": "rimraf build",
"format": "pnpm prettier && LINT_FIX=1 pnpm lint:all --fix --quiet",
"lint": "eslint --cache --cache-location ../../node_modules/.cache/eslint",
"lint:all": "pnpm lint 'src/**/*.{ts,tsx}' 'test/**/*.{ts,tsx}'",
"lint:all": "pnpm lint 'src/**/*.{mts,ts,tsx}' 'test/**/*.{mts,ts,tsx}'",
"precommit": "echo lint-staged runs from root",
"prettier": "prettier --write '*.{ts,tsx,js,html,jsx,md}' '{src,test}/**/*.{ts,tsx,js,html,jsx,md}'",
"test": "PROJECT_JEST=1 jest --passWithNoTests",
"test:coverage": "pnpm run test --verbose --coverage",
"test:e2e": "pnpm run test --config jest-e2e.config.cjs",
"test:e2e:coverage": "pnpm test:coverage --config jest-e2e.config.cjs",
"prettier": "prettier --write '*.{mts,ts,tsx,js,html,jsx,md}' '{src,test}/**/*.{mts,ts,tsx,js,html,jsx,md}'",
"test": "NODE_OPTIONS=--experimental-vm-modules PROJECT_JEST=1 jest --passWithNoTests --config jest.config.cjs",
"test:coverage": "NODE_OPTIONS=--experimental-vm-modules PROJECT_JEST=1 jest --passWithNoTests --verbose --coverage --config jest.config.cjs",
"test:e2e": "NODE_OPTIONS=--experimental-vm-modules PROJECT_JEST=1 jest --passWithNoTests --config jest-e2e.config.cjs",
"test:e2e:coverage": "NODE_OPTIONS=--experimental-vm-modules PROJECT_JEST=1 jest --passWithNoTests --verbose --coverage --config jest-e2e.config.cjs",
"tsnodeenv": "NODE_OPTIONS=\"${NODE_OPTIONS:-} --require tsconfig-paths/register\" TS_NODE_PROJECT=\"../../tsconfig.cjs.json\"",
"upkeep": "cd ../.. && pnpm upkeep"
},
Expand Down
12 changes: 12 additions & 0 deletions packages/coil-extension/jest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// FROM UPKEEP TEMPLATE
import { createRequire } from 'node:module'

const require = createRequire(import.meta.url)
const config = require('./jest.config.cjs')

config.extensionsToTreatAsEsm = ['.mts']
config.moduleFileExtensions.push('mts')
config.testMatch = config.testMatch.concat(
config.testMatch.map( tm => tm.replace('.ts?', '.mts?')))

export default config
12 changes: 6 additions & 6 deletions packages/coil-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@
"ff:load-ext": "ts-node --swc src/scripts/load-extension-into-ff.ts",
"format": "pnpm prettier && LINT_FIX=1 pnpm lint:all --fix --quiet",
"lint": "eslint --cache --cache-location ../../node_modules/.cache/eslint",
"lint:all": "pnpm lint 'src/**/*.{ts,tsx}' 'test/**/*.{ts,tsx}'",
"lint:all": "pnpm lint 'src/**/*.{mts,ts,tsx}' 'test/**/*.{mts,ts,tsx}'",
"precommit": "echo lint-staged runs from root",
"prettier": "prettier --write '*.{ts,tsx,js,html,jsx,md}' '{src,test}/**/*.{ts,tsx,js,html,jsx,md}'",
"prettier": "prettier --write '*.{mts,ts,tsx,js,html,jsx,md}' '{src,test}/**/*.{mts,ts,tsx,js,html,jsx,md}'",
"publish:dev": "./scripts/publish-coildev-chrome-store.sh",
"publish:preview": "WEXT_SHIPIT_CHROME_EXTENSION_ID=iehmfkldnblennopinmmagfidpflefkp WEXT_MANIFEST_SUFFIX=Preview ./scripts/publish-coildev-chrome-store.sh",
"serve:dist": "http-server -p 4000 dist",
"serve:fixtures": "http-server -p 4000 test/fixtures",
"serve:fixtures-iframes": "http-server -p 4000 test/fixtures/iframes",
"test": "PROJECT_JEST=1 jest --passWithNoTests",
"test:coverage": "pnpm run test --verbose --coverage",
"test:e2e": "pnpm run test --config jest-e2e.config.cjs",
"test:e2e:coverage": "pnpm test:coverage --config jest-e2e.config.cjs",
"test": "NODE_OPTIONS=--experimental-vm-modules PROJECT_JEST=1 jest --passWithNoTests --config jest.config.cjs",
"test:coverage": "NODE_OPTIONS=--experimental-vm-modules PROJECT_JEST=1 jest --passWithNoTests --verbose --coverage --config jest.config.cjs",
"test:e2e": "NODE_OPTIONS=--experimental-vm-modules PROJECT_JEST=1 jest --passWithNoTests --config jest-e2e.config.cjs",
"test:e2e:coverage": "NODE_OPTIONS=--experimental-vm-modules PROJECT_JEST=1 jest --passWithNoTests --verbose --coverage --config jest-e2e.config.cjs",
"tsnodeenv": "NODE_OPTIONS=\"${NODE_OPTIONS:-} --require tsconfig-paths/register\" TS_NODE_PROJECT=\"../../tsconfig.cjs.json\"",
"upkeep": "cd ../.. && pnpm upkeep",
"web-ext-reload": "web-ext run --reload -s $PWD/dist -p default-release"
Expand Down
12 changes: 12 additions & 0 deletions packages/coil-local-server/jest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// FROM UPKEEP TEMPLATE
import { createRequire } from 'node:module'

const require = createRequire(import.meta.url)
const config = require('./jest.config.cjs')

config.extensionsToTreatAsEsm = ['.mts']
config.moduleFileExtensions.push('mts')
config.testMatch = config.testMatch.concat(
config.testMatch.map( tm => tm.replace('.ts?', '.mts?')))

export default config
12 changes: 6 additions & 6 deletions packages/coil-local-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
"generate-code": "pnpm generate-graphql && pnpm prettier && pnpm lint:all --fix",
"generate-graphql": "graphql-codegen --config codegen.yml",
"lint": "eslint --cache --cache-location ../../node_modules/.cache/eslint",
"lint:all": "pnpm lint 'src/**/*.{ts,tsx}' 'test/**/*.{ts,tsx}'",
"lint:all": "pnpm lint 'src/**/*.{mts,ts,tsx}' 'test/**/*.{mts,ts,tsx}'",
"precommit": "echo lint-staged runs from root",
"prettier": "prettier --write '*.{ts,tsx,js,html,jsx,md}' '{src,test}/**/*.{ts,tsx,js,html,jsx,md}'",
"test": "PROJECT_JEST=1 jest --passWithNoTests",
"test:coverage": "pnpm run test --verbose --coverage",
"test:e2e": "pnpm run test --config jest-e2e.config.cjs",
"test:e2e:coverage": "pnpm test:coverage --config jest-e2e.config.cjs",
"prettier": "prettier --write '*.{mts,ts,tsx,js,html,jsx,md}' '{src,test}/**/*.{mts,ts,tsx,js,html,jsx,md}'",
"test": "NODE_OPTIONS=--experimental-vm-modules PROJECT_JEST=1 jest --passWithNoTests --config jest.config.cjs",
"test:coverage": "NODE_OPTIONS=--experimental-vm-modules PROJECT_JEST=1 jest --passWithNoTests --verbose --coverage --config jest.config.cjs",
"test:e2e": "NODE_OPTIONS=--experimental-vm-modules PROJECT_JEST=1 jest --passWithNoTests --config jest-e2e.config.cjs",
"test:e2e:coverage": "NODE_OPTIONS=--experimental-vm-modules PROJECT_JEST=1 jest --passWithNoTests --verbose --coverage --config jest-e2e.config.cjs",
"tsnodeenv": "NODE_OPTIONS=\"${NODE_OPTIONS:-} --require tsconfig-paths/register\" TS_NODE_PROJECT=\"../../tsconfig.cjs.json\"",
"upkeep": "cd ../.. && pnpm upkeep"
},
Expand Down
12 changes: 12 additions & 0 deletions packages/coil-monorepo-upkeep/jest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// FROM UPKEEP TEMPLATE
import { createRequire } from 'node:module'

const require = createRequire(import.meta.url)
const config = require('./jest.config.cjs')

config.extensionsToTreatAsEsm = ['.mts']
config.moduleFileExtensions.push('mts')
config.testMatch = config.testMatch.concat(
config.testMatch.map( tm => tm.replace('.ts?', '.mts?')))

export default config
12 changes: 6 additions & 6 deletions packages/coil-monorepo-upkeep/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
"clean:build": "rimraf build",
"format": "pnpm prettier && LINT_FIX=1 pnpm lint:all --fix --quiet",
"lint": "eslint --cache --cache-location ../../node_modules/.cache/eslint",
"lint:all": "pnpm lint 'src/**/*.{ts,tsx}' 'test/**/*.{ts,tsx}'",
"lint:all": "pnpm lint 'src/**/*.{mts,ts,tsx}' 'test/**/*.{mts,ts,tsx}'",
"precommit": "echo lint-staged runs from root",
"prettier": "prettier --write '*.{ts,tsx,js,html,jsx,md}' '{src,test}/**/*.{ts,tsx,js,html,jsx,md}'",
"test": "PROJECT_JEST=1 jest --passWithNoTests",
"test:coverage": "pnpm run test --verbose --coverage",
"test:e2e": "pnpm run test --config jest-e2e.config.cjs",
"test:e2e:coverage": "pnpm test:coverage --config jest-e2e.config.cjs",
"prettier": "prettier --write '*.{mts,ts,tsx,js,html,jsx,md}' '{src,test}/**/*.{mts,ts,tsx,js,html,jsx,md}'",
"test": "NODE_OPTIONS=--experimental-vm-modules PROJECT_JEST=1 jest --passWithNoTests --config jest.config.cjs",
"test:coverage": "NODE_OPTIONS=--experimental-vm-modules PROJECT_JEST=1 jest --passWithNoTests --verbose --coverage --config jest.config.cjs",
"test:e2e": "NODE_OPTIONS=--experimental-vm-modules PROJECT_JEST=1 jest --passWithNoTests --config jest-e2e.config.cjs",
"test:e2e:coverage": "NODE_OPTIONS=--experimental-vm-modules PROJECT_JEST=1 jest --passWithNoTests --verbose --coverage --config jest-e2e.config.cjs",
"tsnodeenv": "NODE_OPTIONS=\"${NODE_OPTIONS:-} --require tsconfig-paths/register\" TS_NODE_PROJECT=\"../../tsconfig.cjs.json\"",
"upkeep": "cd ../.. && pnpm upkeep"
},
Expand Down
22 changes: 16 additions & 6 deletions packages/coil-monorepo-upkeep/src/commands/doUpKeep/doUpKeep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,18 @@ function setCommonScriptsAndMergeOverrides(
}
const githubPath = rootPackageJSON.repository.url.split(':')[1].slice(0, -4)

const jest = (...rest: string[]) => {
return `NODE_OPTIONS=--experimental-vm-modules PROJECT_JEST=1 jest --passWithNoTests ${rest.join(
' '
)}`
}

const coverage = '--verbose --coverage'
const e2eConf = '--config jest-e2e.config.cjs'
const unitConf = '--config jest.config.cjs'
let updated: PackageJSON = {
...subPackageJSON,
// TODO: use workspace
version: '0.0.0',
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
homepage: `https://github.com/${githubPath}/tree/main/${pathFromRoot}`,
Expand All @@ -131,7 +141,7 @@ function setCommonScriptsAndMergeOverrides(
postinstall: undefined!,
precommit: 'echo lint-staged runs from root',
prettier:
"prettier --write '*.{ts,tsx,js,html,jsx,md}' '{src,test}/**/*.{ts,tsx,js,html,jsx,md}'",
"prettier --write '*.{mts,ts,tsx,js,html,jsx,md}' '{src,test}/**/*.{mts,ts,tsx,js,html,jsx,md}'",
format: 'pnpm prettier && LINT_FIX=1 pnpm lint:all --fix --quiet',
'build:ts': 'tsc --build tsconfig.build.json',
'build:ts:watch': 'pnpm build:ts --watch',
Expand All @@ -145,12 +155,12 @@ function setCommonScriptsAndMergeOverrides(
tsnodeenv:
'NODE_OPTIONS="${NODE_OPTIONS:-} --require tsconfig-paths/register" TS_NODE_PROJECT="../../tsconfig.cjs.json"',
upkeep: 'cd ../.. && pnpm upkeep',
'lint:all': "pnpm lint 'src/**/*.{ts,tsx}' 'test/**/*.{ts,tsx}'",
'lint:all': "pnpm lint 'src/**/*.{mts,ts,tsx}' 'test/**/*.{mts,ts,tsx}'",
lint: 'eslint --cache --cache-location ../../node_modules/.cache/eslint',
'test:e2e': 'pnpm run test --config jest-e2e.config.cjs',
'test:e2e:coverage': 'pnpm test:coverage --config jest-e2e.config.cjs',
test: 'PROJECT_JEST=1 jest --passWithNoTests',
'test:coverage': 'pnpm run test --verbose --coverage'
'test:e2e': jest(e2eConf),
'test:e2e:coverage': jest(coverage, e2eConf),
test: jest(unitConf),
'test:coverage': jest(coverage, unitConf)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// FROM UPKEEP TEMPLATE
import { createRequire } from 'node:module'

const require = createRequire(import.meta.url)
const config = require('./jest.config.cjs')

config.extensionsToTreatAsEsm = ['.mts']
config.moduleFileExtensions.push('mts')
config.testMatch = config.testMatch.concat(
config.testMatch.map( tm => tm.replace('.ts?', '.mts?')))

export default config
12 changes: 12 additions & 0 deletions packages/coil-privacypass-sjcl/jest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// FROM UPKEEP TEMPLATE
import { createRequire } from 'node:module'

const require = createRequire(import.meta.url)
const config = require('./jest.config.cjs')

config.extensionsToTreatAsEsm = ['.mts']
config.moduleFileExtensions.push('mts')
config.testMatch = config.testMatch.concat(
config.testMatch.map( tm => tm.replace('.ts?', '.mts?')))

export default config
12 changes: 6 additions & 6 deletions packages/coil-privacypass-sjcl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
"clean:build": "rimraf build",
"format": "pnpm prettier && LINT_FIX=1 pnpm lint:all --fix --quiet",
"lint": "eslint --cache --cache-location ../../node_modules/.cache/eslint",
"lint:all": "pnpm lint 'src/**/*.{ts,tsx}' 'test/**/*.{ts,tsx}'",
"lint:all": "pnpm lint 'src/**/*.{mts,ts,tsx}' 'test/**/*.{mts,ts,tsx}'",
"precommit": "echo lint-staged runs from root",
"prettier": "prettier --write '*.{ts,tsx,js,html,jsx,md}' '{src,test}/**/*.{ts,tsx,js,html,jsx,md}'",
"test": "PROJECT_JEST=1 jest --passWithNoTests",
"test:coverage": "pnpm run test --verbose --coverage",
"test:e2e": "pnpm run test --config jest-e2e.config.cjs",
"test:e2e:coverage": "pnpm test:coverage --config jest-e2e.config.cjs",
"prettier": "prettier --write '*.{mts,ts,tsx,js,html,jsx,md}' '{src,test}/**/*.{mts,ts,tsx,js,html,jsx,md}'",
"test": "NODE_OPTIONS=--experimental-vm-modules PROJECT_JEST=1 jest --passWithNoTests --config jest.config.cjs",
"test:coverage": "NODE_OPTIONS=--experimental-vm-modules PROJECT_JEST=1 jest --passWithNoTests --verbose --coverage --config jest.config.cjs",
"test:e2e": "NODE_OPTIONS=--experimental-vm-modules PROJECT_JEST=1 jest --passWithNoTests --config jest-e2e.config.cjs",
"test:e2e:coverage": "NODE_OPTIONS=--experimental-vm-modules PROJECT_JEST=1 jest --passWithNoTests --verbose --coverage --config jest-e2e.config.cjs",
"tsnodeenv": "NODE_OPTIONS=\"${NODE_OPTIONS:-} --require tsconfig-paths/register\" TS_NODE_PROJECT=\"../../tsconfig.cjs.json\"",
"upkeep": "cd ../.. && pnpm upkeep"
},
Expand Down
12 changes: 12 additions & 0 deletions packages/coil-puppeteer-utils/jest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// FROM UPKEEP TEMPLATE
import { createRequire } from 'node:module'

const require = createRequire(import.meta.url)
const config = require('./jest.config.cjs')

config.extensionsToTreatAsEsm = ['.mts']
config.moduleFileExtensions.push('mts')
config.testMatch = config.testMatch.concat(
config.testMatch.map( tm => tm.replace('.ts?', '.mts?')))

export default config
Loading
Loading