-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add global test framework and tests
- Loading branch information
Showing
10 changed files
with
2,176 additions
and
237 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
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 @@ | ||
node_modules | ||
build | ||
coverage | ||
node_modules |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const path = require('path') | ||
const { lstatSync, readdirSync } = require('fs') | ||
|
||
// get listing of packages in the mono repo | ||
const basePath = path.resolve(__dirname, 'packages') | ||
const packages = readdirSync(basePath) | ||
.filter((name) => { | ||
return lstatSync(path.join(basePath, name)).isDirectory() | ||
}) | ||
.sort((a, b) => b.length - a.length) | ||
|
||
// node_modules that need babel transform e.g. because not export cjs | ||
const esmodules = ['@ipld/unixfs', 'actor'].join('|') | ||
|
||
module.exports = { | ||
collectCoverage: true, | ||
coverageReporters: ['json', 'lcov', 'text', 'clover', 'text-summary'], | ||
projects: packages.map((d) => ({ | ||
displayName: d, | ||
clearMocks: true, | ||
// testEnvironment: 'jsdom', | ||
testEnvironment: './jest.env.js', | ||
testMatch: [`<rootDir>/packages/${d}/**/*.test.[jt]s?(x)`], | ||
// setupFilesAfterEnv: ['<rootDir>/jest.setup.js'], | ||
snapshotFormat: { | ||
printBasicPrototype: false | ||
}, | ||
transformIgnorePatterns: [`/node_modules/(?!${esmodules})`] | ||
})) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const JSDOMEnvironment = require('jest-environment-jsdom') | ||
const { TransformStream } = require('stream/web') | ||
const { Blob, File } = require('@web-std/file') | ||
|
||
// Extends the default JSDOMEnvironment to add globals that are present in all | ||
// browsers and NodeJS that have not yet been added to the jsdom environment. | ||
module.exports = class extends JSDOMEnvironment { | ||
constructor (config, options) { | ||
super(config, options) | ||
Object.assign(this.global, { | ||
TextEncoder, | ||
TextDecoder, | ||
TransformStream, | ||
Blob, | ||
File | ||
}) | ||
} | ||
} |
Oops, something went wrong.