-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: esm collision between default and named exports (#6)
- Loading branch information
Showing
23 changed files
with
168 additions
and
17 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,3 +1,5 @@ | ||
coverage/** | ||
dist/** | ||
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
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,17 @@ | ||
const TestEnvironment = require('jest-environment-emit/node').default; | ||
|
||
class E2ETestEnvironment extends TestEnvironment { | ||
constructor(config, context) { | ||
super(config, context); | ||
this.counter = 2; | ||
} | ||
|
||
async teardown() { | ||
await super.teardown(); | ||
if (this.counter !== 0) { | ||
throw new Error('There was an issue with listeners registration or execution'); | ||
} | ||
} | ||
} | ||
|
||
module.exports = E2ETestEnvironment; |
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/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,6 @@ | ||
import index from './dist/index.js'; | ||
|
||
const { WithEmitter } = index; | ||
|
||
export { WithEmitter }; | ||
export default WithEmitter; |
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,7 @@ | ||
import jsdom from './dist/jsdom.js'; | ||
|
||
const { TestEnvironment } = jsdom; | ||
|
||
export { TestEnvironment }; | ||
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/node'); |
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,6 @@ | ||
import node from './dist/node.js'; | ||
|
||
const { TestEnvironment } = node; | ||
|
||
export { TestEnvironment }; | ||
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 @@ | ||
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,18 @@ | ||
{ | ||
"name": "@jest-environment-emit/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-environment-emit": "file:../jest-environment-emit-1.0.0.tgz" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^5.3.3" | ||
} | ||
} |
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,16 @@ | ||
const assert = require('assert'); | ||
|
||
const index = require('jest-environment-emit'); | ||
assert(typeof index.default === 'function', 'jest-environment-emit should have a function as its default export'); | ||
assert.strictEqual(index.default, index.WithEmitter, 'jest-environment-emit should have a named alternative to its default export'); | ||
|
||
const jsdom = require('jest-environment-emit/jsdom'); | ||
assert(typeof jsdom.default === 'function', 'jest-environment-emit/jsdom should have a function as its default export'); | ||
assert.strictEqual(jsdom.default, jsdom.TestEnvironment, 'jest-environment-emit/jsdom should have a named export `TestEnvironment`'); | ||
|
||
const node = require('jest-environment-emit/node'); | ||
assert(typeof node.default === 'function', 'jest-environment-emit/node should have a function as its default export'); | ||
assert.strictEqual(node.default, node.TestEnvironment, 'jest-environment-emit/node should have a named export `TestEnvironment`'); | ||
|
||
const debug = require('jest-environment-emit/debug'); | ||
assert(typeof debug.aggregateLogs === 'function', 'jest-environment-emit/debug should have a named export `aggregateLogs`'); |
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,16 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var jest_environment_emit_1 = require("jest-environment-emit"); | ||
var jsdom_1 = require("jest-environment-emit/jsdom"); | ||
var node_1 = require("jest-environment-emit/node"); | ||
var debug_1 = require("jest-environment-emit/debug"); | ||
function assertType(_actual) { | ||
// no-op | ||
} | ||
assertType(jest_environment_emit_1.default); | ||
assertType(jest_environment_emit_1.WithEmitter); | ||
assertType(jsdom_1.default); | ||
assertType(jsdom_1.TestEnvironment); | ||
assertType(node_1.default); | ||
assertType(node_1.TestEnvironment); | ||
assertType(debug_1.aggregateLogs); |
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,17 @@ | ||
import assert from 'assert'; | ||
|
||
const index = await import('jest-environment-emit'); | ||
assert(typeof index.default === 'function', 'jest-environment-emit should have a function as its default export'); | ||
assert.strictEqual(index.default, index.WithEmitter, 'jest-environment-emit should have a named alternative to its default export'); | ||
|
||
const jsdom = await import('jest-environment-emit/jsdom'); | ||
assert(typeof jsdom.default === 'function', 'jest-environment-emit/jsdom should have a function as its default export'); | ||
assert.strictEqual(jsdom.default, jsdom.TestEnvironment, 'jest-environment-emit/jsdom should have a named export `TestEnvironment`'); | ||
|
||
const node = await import('jest-environment-emit/node'); | ||
assert(typeof node.default === 'function', 'jest-environment-emit/node should have a function as its default export'); | ||
assert.strictEqual(node.default, node.TestEnvironment, 'jest-environment-emit/node should have a named export `TestEnvironment`'); | ||
|
||
const debug = await import('jest-environment-emit/debug'); | ||
assert(typeof debug.aggregateLogs === 'function', 'jest-environment-emit/debug should have a named export `aggregateLogs`'); | ||
|
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,16 @@ | ||
import WithEmitter, { WithEmitter as WithEmitterNamed } from 'jest-environment-emit'; | ||
import JsdomTestEnvironment, { TestEnvironment as JsdomTestEnvironmentNamed } from 'jest-environment-emit/jsdom'; | ||
import NodeTestEnvironment, { TestEnvironment as NodeTestEnvironmentNamed } from 'jest-environment-emit/node'; | ||
import { aggregateLogs } from 'jest-environment-emit/debug'; | ||
|
||
function assertType<T>(_actual: T): void { | ||
// no-op | ||
} | ||
|
||
assertType<Function>(WithEmitter); | ||
assertType<Function>(WithEmitterNamed); | ||
assertType<Function>(JsdomTestEnvironment); | ||
assertType<Function>(JsdomTestEnvironmentNamed); | ||
assertType<Function>(NodeTestEnvironment); | ||
assertType<Function>(NodeTestEnvironmentNamed); | ||
assertType<Function>(aggregateLogs); |
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
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