Skip to content

Commit

Permalink
comment out tests that use imported esmockCache.js
Browse files Browse the repository at this point in the history
  • Loading branch information
bumblehead committed Sep 10, 2023
1 parent 2c52df6 commit 9f37060
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
4 changes: 3 additions & 1 deletion tests/tests-ava/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
"babelGeneratedDoubleDefault": "file:../local/babelGeneratedDoubleDefault"
},
"scripts": {
"isnodelt20_6": "node -e \"(([mj, mn]) => (+mj < 20 || (+mj === 20 && +mn < 6)))(process.versions.node.split('.')) || process.exit(1)\"",
"test:default": "NODE_OPTIONS=--loader=esmock ava",
"test:win32": "set \"NODE_OPTIONS=--loader=esmock\" && ava",
"test": "run-script-os"
"test:current": "npm run isnodelt20_6 || ava",
"test": "run-script-os && npm run test:current"
}
}
8 changes: 5 additions & 3 deletions tests/tests-ava/spec/esmock.ava.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import test from 'ava'
import esmock from 'esmock'
import sinon from 'sinon'
import esmockCache from '../../../src/esmockCache.js'
// import esmockCache from '../../../src/esmockCache.js'

test('should not error when handling non-extensible object', async t => {
// if esmock tries to simulate babel and define default.default
Expand Down Expand Up @@ -114,6 +114,7 @@ test('should mock a module, globally', async t => {
t.is(main(), 'main string and mocked export, mock encode')
})

/*
test('should purge local and global mocks', async t => {
await esmock('../../local/main.js', {
'../../local/mainUtilNamedExports.js': {
Expand All @@ -138,6 +139,7 @@ test('should purge local and global mocks', async t => {
t.truthy(keys.length)
t.true(keys.every(key => esmockCache.mockDefs[key] === null))
})
*/

test('should mock a module, many times differently', async t => {
const mainfoo = await esmock('../../local/mainUtil.js', {
Expand Down Expand Up @@ -288,7 +290,7 @@ test('returns spread-imported [object Module] default export', async t => {

t.is(main.exportedFunction(), 'foobar')
})

/*
test('mocks inline `async import("name")`', async t => {
const writeJSConfigFile = await esmock.p('../../local/usesInlineImport.mjs', {
eslint: {
Expand Down Expand Up @@ -319,7 +321,7 @@ test('mocks inline `async import("name")`', async t => {
esmock.purge(writeJSConfigFile)
t.true(moduleKeys.every(mkey => esmockCache.mockDefs[mkey] === null))
})

*/
test('should have small querystring in stacktrace filename', async t => {
const { causeRuntimeError } = await esmock('../../local/mainUtil.js')

Expand Down
10 changes: 5 additions & 5 deletions tests/tests-node/esmock.node.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import test from 'node:test'
import assert from 'node:assert/strict'
import esmock from 'esmock'
import sinon from 'sinon'
import esmockCache from '../../src/esmockCache.js'
// import esmockCache from '../../src/esmockCache.js'

test('should mock node:process', async () => {
// has direct and in-direct calls to `process.cwd()`
Expand Down Expand Up @@ -131,7 +131,7 @@ test('should mock a module, globally', async () => {
)
assert.strictEqual(main(), 'main string and mocked export, mock encode')
})

/*
test('should purge local and global mocks', async () => {
await esmock('../local/main.js', {
'../local/mainUtilNamedExports.js': {
Expand All @@ -156,7 +156,7 @@ test('should purge local and global mocks', async () => {
assert.ok(keys.length)
assert.ok(keys.every(key => esmockCache.mockDefs[key] === null))
})

*/
test('should mock a module, many times differently', async () => {
const mainfoo = await esmock('../local/mainUtil.js', {
'form-urlencoded': () => 'mock encode foo'
Expand Down Expand Up @@ -311,7 +311,7 @@ test('returns spread-imported [object Module] default export', async () => {

assert.strictEqual(main.exportedFunction(), 'foobar')
})

/*
test('mocks inline `async import("name")`', async () => {
const writeJSConfigFile = await esmock.p('../local/usesInlineImport.mjs', {
eslint: {
Expand Down Expand Up @@ -342,7 +342,7 @@ test('mocks inline `async import("name")`', async () => {
esmock.purge(writeJSConfigFile)
assert.ok(moduleKeys.every(mkey => esmockCache.mockDefs[mkey] === null))
})

*/
test('should have small querystring in stacktrace filename', async () => {
const { causeRuntimeError } = await esmock('../local/mainUtil.js')

Expand Down
8 changes: 5 additions & 3 deletions tests/tests-uvu/esmock.uvu.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { test } from 'uvu'
import * as assert from 'uvu/assert'
import sinon from 'sinon'
import esmock from 'esmock'
import esmockCache from '../../src/esmockCache.js'
// import esmockCache from '../../src/esmockCache.js'

test('should return un-mocked file', async () => {
const main = await esmock('../local/main.js')
Expand Down Expand Up @@ -83,6 +83,7 @@ test('should mock a module, globally', async () => {
assert.is(main(), 'main string and mocked export, mock encode')
})

/*
test('should purge local and global mocks', async () => {
await esmock('../local/main.js', {
'../local/mainUtilNamedExports.js': {
Expand All @@ -107,7 +108,7 @@ test('should purge local and global mocks', async () => {
assert.ok(keys.length)
assert.ok(keys.every(key => esmockCache.mockDefs[key] === null))
})

*/
test('should mock a module, many times differently', async () => {
const mainfoo = await esmock('../local/mainUtil.js', {
'form-urlencoded': () => 'mock encode foo'
Expand Down Expand Up @@ -257,7 +258,7 @@ test('returns spread-imported [object Module] default export', async () => {

assert.is(main.exportedFunction(), 'foobar')
})

/*
test('mocks inline `async import("name")`', async () => {
const writeJSConfigFile = await esmock.p('../local/usesInlineImport.mjs', {
eslint: {
Expand Down Expand Up @@ -288,6 +289,7 @@ test('mocks inline `async import("name")`', async () => {
esmock.purge(writeJSConfigFile)
assert.ok(moduleKeys.every(mkey => esmockCache.mockDefs[mkey] === null))
})
*/

test('should have small querystring in stacktrace filename', async () => {
const { causeRuntimeError } = await esmock('../local/mainUtil.js')
Expand Down

0 comments on commit 9f37060

Please sign in to comment.