Skip to content

Commit

Permalink
feat!: esm only build
Browse files Browse the repository at this point in the history
  • Loading branch information
AuHau committed Sep 29, 2022
1 parent e928f6d commit 3c90faf
Show file tree
Hide file tree
Showing 56 changed files with 11,048 additions and 15,804 deletions.
33 changes: 0 additions & 33 deletions .babelrc.js

This file was deleted.

3 changes: 2 additions & 1 deletion .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
extends: ['plugin:@typescript-eslint/recommended', 'prettier', 'plugin:prettier/recommended'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2018,
ecmaVersion: 2020,
project: './tsconfig.test.json',
},
env: {
Expand Down Expand Up @@ -89,6 +89,7 @@ module.exports = {
],
'require-await': 'off',
'@typescript-eslint/promise-function-async': 'error',
// '@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unused-vars': 'off',
Expand Down
27 changes: 0 additions & 27 deletions build-fixup

This file was deleted.

File renamed without changes.
8 changes: 8 additions & 0 deletions jest-puppeteer.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
launch: {
headless: !(process.env.TEST_HEADLESS === 'false'),
devtools: process.env.TEST_DEVTOOLS === 'true',
args: ['--allow-file-access-from-files'],
dumpio: true, // Forwards browser console into test console for easier debugging
},
}
5 changes: 0 additions & 5 deletions jest-puppeteer.config.js

This file was deleted.

57 changes: 30 additions & 27 deletions jest.config.ts → jest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
* For a detailed explanation regarding each configuration property and type check, visit:
* https://jestjs.io/docs/en/configuration.html
*/
import type { Config } from '@jest/types'
import { glob } from 'glob'
import Glob from 'glob'
import * as Path from 'path'
import { dirname } from 'path'
import { fileURLToPath } from 'url'

export async function getBrowserPathMapping(): Promise<{ [aliasNodeReference: string]: string }> {
const browserSourceFiles = await new Promise<{ [aliasNodeReference: string]: string }>((resolve, reject) => {
glob('src/**/*.browser.ts', (err, browserSourceCodes) => {
const __dirname = dirname(fileURLToPath(import.meta.url))

export async function getBrowserPathMapping () {
const browserSourceFiles = await new Promise((resolve, reject) => {
Glob.glob('src/**/*.browser.ts', (err, browserSourceCodes) => {
if (err) reject(err)
browserSourceCodes = browserSourceCodes.map(match => Path.resolve(__dirname, match))
const codePathMapping: { [nodeFullPath: string]: string } = {}
const codePathMapping = {}
browserSourceCodes.map(browserFullPath => {
const filePathArray = browserFullPath.split('.')
filePathArray.pop()
Expand All @@ -29,57 +32,57 @@ export async function getBrowserPathMapping(): Promise<{ [aliasNodeReference: st
return browserSourceFiles
}

export default async (): Promise<Config.InitialOptions> => {
export default async () => {
return {
// Indicates whether the coverage information should be collected while executing the test
// collectCoverage: false,

// This will setup the prerequisites for the tests to run
globalSetup: './tests-setup.ts',
globalSetup: './test/jest/tests-setup.ts',

// The directory where Jest should output its coverage files
coverageDirectory: 'coverage',

// Custom sequencer that priorities running unit tests before integration tests
testSequencer: '<rootDir>/test-type-sequencer.js',
testSequencer: './test/jest/test-type-sequencer.js',

// An array of regexp pattern strings used to skip coverage collection
coveragePathIgnorePatterns: ['/node_modules/'],

// An array of directory names to be searched recursively up from the requiring module's location
moduleDirectories: ['node_modules'],
extensionsToTreatAsEsm: ['.ts'],

transform: {
'.ts': './test/jest/test-transformer.js',
},
// Run tests from one or more projects
projects: [
// We don't have any DOM specific tests atm.
// {
// displayName: 'dom:unit',
// testRegex: 'test/unit/.*\\.browser\\.spec\\.ts',
// moduleNameMapper: await getBrowserPathMapping(),
// preset: 'jest-puppeteer',
// },
{
displayName: 'node:unit',
testEnvironment: 'node',
globalSetup: '',
testRegex: 'test/unit/((?!\\.browser).)*\\.spec\\.ts',
extensionsToTreatAsEsm: ['.ts'],
transform: {
'.ts': './test/jest/test-transformer.js',
},
},
{
displayName: 'dom:integration',
testRegex: 'test/integration/.*\\.browser\\.spec\\.ts',
moduleNameMapper: await getBrowserPathMapping(),
preset: 'jest-puppeteer',
extensionsToTreatAsEsm: ['.ts'],
transform: {
'.ts': './test/jest/test-transformer.js',
},
},
{
displayName: 'node:integration',
testEnvironment: 'node',
testRegex: 'test/integration/((?!\\.browser).)*\\.spec\\.ts',
extensionsToTreatAsEsm: ['.ts'],
transform: {
'.ts': './test/jest/test-transformer.js',
},
},
] as unknown[] as string[], // bad types

// The root directory that Jest should scan for tests and modules within
rootDir: 'test',

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
testPathIgnorePatterns: ['/node_modules/'],
],
}
}
Loading

0 comments on commit 3c90faf

Please sign in to comment.