-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: default and named exports (#68)
- Loading branch information
Showing
28 changed files
with
203 additions
and
44 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,4 +1,6 @@ | ||
coverage/** | ||
dist/** | ||
e2e/** | ||
package-e2e/** | ||
*.js | ||
*.mjs |
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 @@ | ||
/* Jest 27 fallback */ | ||
module.exports = require('./dist/debug'); |
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 @@ | ||
export * from './dist/debug.js'; |
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 @@ | ||
/* Jest 27 fallback */ | ||
module.exports = require('./dist/environment-decorator'); | ||
module.exports = require('./dist/environment-decorator').default; |
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,5 @@ | ||
import environmentDecorator from './dist/environment-decorator.js'; | ||
|
||
const { default: WithMetadata } = environmentDecorator; | ||
|
||
export default WithMetadata; |
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 @@ | ||
/* Jest 27 fallback */ | ||
module.exports = require('./dist/environment-jsdom'); | ||
module.exports = require('./dist/environment-jsdom').default; |
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,5 @@ | ||
import environmentJsdom from './dist/environment-jsdom.js'; | ||
|
||
const { default: TestEnvironment } = environmentJsdom; | ||
|
||
export default TestEnvironment; |
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 @@ | ||
/* Jest 27 fallback */ | ||
module.exports = require('./dist/environment-listener'); | ||
module.exports = require('./dist/environment-listener').default; |
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,5 @@ | ||
import environmentListener from './dist/environment-listener.js'; | ||
|
||
const { default: listener } = environmentListener; | ||
|
||
export default listener; |
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 @@ | ||
/* Jest 27 fallback */ | ||
module.exports = require('./dist/environment-node'); | ||
module.exports = require('./dist/environment-node').default; |
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,5 @@ | ||
import environmentNode from './dist/environment-node.js'; | ||
|
||
const { default: TestEnvironment } = environmentNode; | ||
|
||
export default TestEnvironment; |
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 @@ | ||
module.exports = require('./dist/index'); |
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 @@ | ||
export * from './dist/index.js'; |
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 @@ | ||
package-lock=false |
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,15 @@ | ||
{ | ||
"name": "@jest-metadata/package-e2e", | ||
"private": true, | ||
"version": "1.0.0", | ||
"description": "", | ||
"scripts": { | ||
"test": "node test.cjs && node test.mjs && tsc", | ||
"test:cjs": "node test.cjs", | ||
"test:mjs": "node test.mjs", | ||
"test:ts": "tsc" | ||
}, | ||
"dependencies": { | ||
"jest-metadata": "file:../package.tar.gz" | ||
} | ||
} |
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 assert = require('assert'); | ||
|
||
const { metadata, state, $Set, $Push, $Merge, $Assign, $Unshift } = require('jest-metadata'); | ||
assert(typeof metadata === 'object', 'jest-metadata should export `metadata` object'); | ||
assert(typeof state === 'object', 'jest-metadata should export `state` object'); | ||
assert(typeof $Set === 'function', 'jest-metadata should export $Set function as a named export'); | ||
assert(typeof $Push === 'function', 'jest-metadata should export $Push function as a named export'); | ||
assert(typeof $Merge === 'function', 'jest-metadata should export $Merge function as a named export'); | ||
assert(typeof $Assign === 'function', 'jest-metadata should export $Assign function as a named export'); | ||
assert(typeof $Unshift === 'function', 'jest-metadata should export $Unshift function as a named export'); | ||
|
||
const { events } = require('jest-metadata/debug'); | ||
assert(typeof events === 'object', 'jest-metadata/debug should export `events` object'); | ||
|
||
const environmentListener = require('jest-metadata/environment-listener'); | ||
assert(typeof environmentListener === 'function', 'jest-metadata/environment-listener should export a class as its default export'); | ||
|
||
const JsdomTestEnvironment = require('jest-metadata/environment-jsdom'); | ||
assert(isClass(JsdomTestEnvironment), 'jest-metadata/environment-jsdom should export a class as its default export'); | ||
|
||
const NodeTestEnvironment = require('jest-metadata/environment-node'); | ||
assert(isClass(NodeTestEnvironment), 'jest-metadata/environment-node should export a class as its default export'); | ||
|
||
const JestMetadataReporter = require('jest-metadata/reporter'); | ||
assert(isClass(JestMetadataReporter), 'jest-metadata/reporter should export a class as its default export'); | ||
assert(typeof JestMetadataReporter.query === 'object', 'jest-metadata/reporter class should export .query helper'); | ||
|
||
function isClass(obj) { | ||
return typeof obj === 'function' && /^class\s/.test(Function.prototype.toString.call(obj)); | ||
} |
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 @@ | ||
import assert from 'assert'; | ||
import { $Set, $Push, $Merge, $Assign, $Unshift, state, metadata } from 'jest-metadata'; | ||
import { events } from 'jest-metadata/debug'; | ||
import JsdomTestEnvironment from 'jest-metadata/environment-jsdom'; | ||
import NodeTestEnvironment from 'jest-metadata/environment-node'; | ||
import environmentListener from 'jest-metadata/environment-listener'; | ||
import JestMetadataReporter from 'jest-metadata/reporter'; | ||
|
||
assert(typeof metadata === 'object', 'jest-metadata should export `metadata` object'); | ||
assert(typeof state === 'object', 'jest-metadata should export `state` object'); | ||
assert(typeof $Set === 'function', 'jest-metadata should export `$Set` function as a named export'); | ||
assert(typeof $Push === 'function', 'jest-metadata should export `$Push` function as a named export'); | ||
assert(typeof $Merge === 'function', 'jest-metadata should export `$Merge` function as a named export'); | ||
assert(typeof $Assign === 'function', 'jest-metadata should export `$Assign` function as a named export'); | ||
assert(typeof $Unshift === 'function', 'jest-metadata should export `$Unshift` function as a named export'); | ||
|
||
assert(typeof events === 'object', 'jest-metadata/debug should export `events` object'); | ||
|
||
assert(typeof environmentListener === 'function', 'jest-metadata/environment-listener should export a function as its default export'); | ||
|
||
assert(isClass(JsdomTestEnvironment), 'jest-metadata/environment-jsdom should export a class as its default export'); | ||
|
||
assert(isClass(NodeTestEnvironment), 'jest-metadata/environment-node should export a class as its default export'); | ||
|
||
assert(isClass(JestMetadataReporter), 'jest-metadata/reporter should export a class as its default export'); | ||
assert(typeof JestMetadataReporter.query === 'object', 'jest-metadata/reporter class should export .query helper'); | ||
|
||
function isClass(obj) { | ||
return typeof obj === 'function' && /^class\s/.test(Function.prototype.toString.call(obj)); | ||
} |
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,34 @@ | ||
import { $Set, $Push, $Merge, $Assign, $Unshift, state, metadata } from 'jest-metadata'; | ||
import { events } from 'jest-metadata/debug'; | ||
import type { GlobalMetadata, Metadata } from 'jest-metadata'; | ||
import JestMetadataReporter from 'jest-metadata/reporter'; | ||
import JsdomTestEnvironment from 'jest-metadata/environment-jsdom'; | ||
import NodeTestEnvironment from 'jest-metadata/environment-node'; | ||
import environmentListener from 'jest-metadata/environment-listener'; | ||
|
||
function assertType<T>(_actual: T): void { | ||
// no-op | ||
} | ||
|
||
assertType<GlobalMetadata>(state); | ||
assertType<Metadata>(metadata); | ||
assertType<Function>($Set); | ||
assertType<Function>($Push); | ||
assertType<Function>($Merge); | ||
assertType<Function>($Assign); | ||
assertType<Function>($Unshift); | ||
|
||
assertType<object>(events); | ||
|
||
assertType<Function>(JestMetadataReporter); | ||
assertType<Function>(JestMetadataReporter.query.globalMetadata); | ||
assertType<Function>(JestMetadataReporter.query.test); | ||
assertType<Function>(JestMetadataReporter.query.filePath); | ||
assertType<Function>(JestMetadataReporter.query.testResult); | ||
assertType<Function>(JestMetadataReporter.query.testCaseResult); | ||
|
||
assertType<Function>(JsdomTestEnvironment); | ||
|
||
assertType<Function>(NodeTestEnvironment); | ||
|
||
assertType<Function>(environmentListener); |
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,14 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2022", | ||
"module": "Node16", | ||
"moduleResolution": "Node16", | ||
"esModuleInterop": true, | ||
"allowSyntheticDefaultImports": true, | ||
"strict": true, | ||
"noEmit": true | ||
}, | ||
"files": [ | ||
"test.ts" | ||
], | ||
} |
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 @@ | ||
/* Jest 27 fallback */ | ||
module.exports = require('./dist/reporter'); | ||
module.exports = require('./dist/reporter').default; |
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,5 @@ | ||
import reporter from './dist/reporter.js'; | ||
|
||
const { default: JestMetadataReporter } = reporter; | ||
|
||
export default JestMetadataReporter; |
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,5 +1,4 @@ | ||
import JestEnvironmentJsdom from 'jest-environment-jsdom'; | ||
import { WithMetadata } from './environment-decorator'; | ||
import WithMetadata from './environment-decorator'; | ||
|
||
export const TestEnvironment = WithMetadata(JestEnvironmentJsdom); | ||
export default TestEnvironment; | ||
export default WithMetadata(JestEnvironmentJsdom); |
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,5 +1,4 @@ | ||
import JestEnvironmentNode from 'jest-environment-node'; | ||
import { WithMetadata } from './environment-decorator'; | ||
import WithMetadata from './environment-decorator'; | ||
|
||
export const TestEnvironment = WithMetadata(JestEnvironmentNode); | ||
export default TestEnvironment; | ||
export default WithMetadata(JestEnvironmentNode); |
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