-
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: use default and named exports exclusively (#7)
- Loading branch information
Showing
15 changed files
with
38 additions
and
73 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 +1 @@ | ||
module.exports = require('./dist/index'); | ||
module.exports = require('./dist/index').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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import index from './dist/index.js'; | ||
|
||
const { WithEmitter } = index; | ||
const { default: 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 |
---|---|---|
@@ -1,2 +1 @@ | ||
/* Jest 27 fallback */ | ||
module.exports = require('./dist/jsdom'); | ||
module.exports = require('./dist/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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
import jsdom from './dist/jsdom.js'; | ||
|
||
const { TestEnvironment } = jsdom; | ||
const { default: 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 +1 @@ | ||
module.exports = require('./dist/node'); | ||
module.exports = require('./dist/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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import node from './dist/node.js'; | ||
|
||
const { TestEnvironment } = node; | ||
const { default: 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
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,16 +1,13 @@ | ||
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 WithEmitter = require('jest-environment-emit'); | ||
assert(typeof WithEmitter === 'function', 'jest-environment-emit should have a function as 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 JestEnvironmentEmitJsDOM = require('jest-environment-emit/jsdom'); | ||
assert(typeof JestEnvironmentEmitJsDOM === 'function', 'jest-environment-emit/jsdom should have a function as its default export'); | ||
|
||
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 JestEnvironmentEmitNode = require('jest-environment-emit/node'); | ||
assert(typeof JestEnvironmentEmitNode === 'function', 'jest-environment-emit/node should have a function as its default export'); | ||
|
||
const debug = require('jest-environment-emit/debug'); | ||
assert(typeof debug.aggregateLogs === 'function', 'jest-environment-emit/debug should have a named export `aggregateLogs`'); |
This file was deleted.
Oops, something went wrong.
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,17 +1,10 @@ | ||
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`'); | ||
|
||
import WithEmitter from 'jest-environment-emit'; | ||
import JestEnvironmentEmitJsDOM from 'jest-environment-emit/jsdom'; | ||
import JestEnvironmentEmitNode from 'jest-environment-emit/node'; | ||
import { aggregateLogs } from 'jest-environment-emit/debug'; | ||
|
||
assert(typeof WithEmitter === 'function', 'jest-environment-emit should have a function as its default export'); | ||
assert(typeof JestEnvironmentEmitJsDOM === 'function', 'jest-environment-emit/jsdom should have a function as its default export'); | ||
assert(typeof JestEnvironmentEmitNode === 'function', 'jest-environment-emit/node should have a function as its default export'); | ||
assert(typeof 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 |
---|---|---|
@@ -1,16 +1,21 @@ | ||
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 WithEmitter from 'jest-environment-emit'; | ||
import type { EnvironmentListenerFn } from 'jest-environment-emit'; | ||
import JsdomTestEnvironment from 'jest-environment-emit/jsdom'; | ||
import NodeTestEnvironment 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); | ||
|
||
assertType<EnvironmentListenerFn>((context, options) => { | ||
context.env.global.__INJECT__ = options; | ||
context.testEvents.on('test_start', ({ event, state }) => { | ||
console.log(event.test.fn.toString(), state.rootDescribeBlock.name, options); | ||
}); | ||
}); |
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 { WithEmitter } from './index'; | ||
import WithEmitter from './index'; | ||
|
||
export const TestEnvironment = WithEmitter(JestEnvironmentJsdom); | ||
export default TestEnvironment; | ||
export default WithEmitter(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 { WithEmitter } from './index'; | ||
import WithEmitter from './index'; | ||
|
||
export const TestEnvironment = WithEmitter(JestEnvironmentNode); | ||
export default TestEnvironment; | ||
export default WithEmitter(JestEnvironmentNode); |