-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #80 from iambumblehead/mv-tests-to-subfolders-with…
…-own-packagejson Mv tests to subfolders with own packagejson
- Loading branch information
Showing
17 changed files
with
239 additions
and
99 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
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
19 changes: 19 additions & 0 deletions
19
tests/local/babelGeneratedDoubleDefault/babelGeneratedDoubleDefault.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,19 @@ | ||
// this undesirable output was commonly generated by babel w browser-breaking | ||
// defineProperty and default.default definitions | ||
|
||
/* eslint-disable */ | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = void 0; | ||
|
||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
|
||
var _default = function _default() { | ||
return 'unmocked default.default'; | ||
}; | ||
|
||
exports["default"] = _default; | ||
/* eslint-enable */ |
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,4 @@ | ||
{ | ||
"description": "problematic cjs file type generated by babel", | ||
"main": "./babelGeneratedDoubleDefault.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 |
---|---|---|
@@ -1,23 +1,28 @@ | ||
import formurlencoded from 'form-urlencoded'; | ||
import babelGeneratedDoubleDefault from 'babelGeneratedDoubleDefault'; | ||
import { | ||
mainUtilNamedExportOne, | ||
mainUtilNamedExportTwo | ||
} from './mainUtilNamedExports.js'; | ||
|
||
const mainUtil = () => 'mainUtil'; | ||
|
||
const createString = () => formurlencoded.default({ | ||
const createString = () => formurlencoded({ | ||
mainUtil : 'a string', | ||
mainUtilNamedExportOneValue : mainUtilNamedExportOne(), | ||
mainUtilNamedExportTwoValue : mainUtilNamedExportTwo() | ||
}); | ||
|
||
const callBabelGeneratedDoubleDefault = o => ( | ||
babelGeneratedDoubleDefault.default(o)); | ||
|
||
const causeRuntimeError = () => mainUtil()(); | ||
|
||
export default mainUtil; | ||
|
||
export { | ||
mainUtil, | ||
createString, | ||
causeRuntimeError | ||
causeRuntimeError, | ||
callBabelGeneratedDoubleDefault | ||
}; |
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,33 +1,37 @@ | ||
{ | ||
"name": "esmock-tests", | ||
"type": "module", | ||
"license": "ISC", | ||
"description": "various esmock unit tests", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/iambumblehead/esmock.git" | ||
}, | ||
"main": "package.json.esmock.export.js", | ||
"dependencies": { | ||
"esmock": "file:..", | ||
"ts-node": "^10.9.1", | ||
"uvu": "0.5.3", | ||
"ava": "^4.0.1", | ||
"eslint": "^8.12.0", | ||
"ts-node": "^10.9.1", | ||
"form-urlencoded": "4.2.1", | ||
"sinon": "^12.0.1", | ||
"form-urlencoded": "^6.0.7", | ||
"run-script-os": "^1.1.6", | ||
"sinon": "^12.0.1" | ||
"check-node-version": "^4.2.1", | ||
"npm-run-all": "^4.1.5", | ||
"babelGeneratedDoubleDefault": "file:./local/babelGeneratedDoubleDefault" | ||
}, | ||
"scripts": { | ||
"test-node-esbuildts": "node --loader=@esbuild-kit/esm-loader --loader=esmock --test ./tests-nodets/*ts", | ||
"test-ava": "npx ava --node-arguments=\"--loader=esmock\" ./tests-ava/*.spec.js", | ||
"test-uvu": "node --loader=esmock ./node_modules/uvu/bin.js ./tests-uvu/", | ||
"test-node": "node --no-warnings --loader=esmock --test ./tests-node/", | ||
"test-node-ts": "node --loader=ts-node/esm --loader=esmock --test ./tests-tsnode/*ts", | ||
"test-node18": "npm run test-node && npm run test-node-ts", | ||
"test-nodeis18": "if (node -v | grep v18); then npm run test-node18; fi;", | ||
"test:default": "npm run test-nodeis18 && npm run test-ava && npm run test-uvu", | ||
"test:windows": "npm run test-ava && npm run test-uvu", | ||
"test": "npm install && run-script-os" | ||
"mini:default": "cd .. && npx esbuild ./src/*js --minify --allow-overwrite --outdir=src", | ||
"mini:win32": "cd .. && cd src && forfiles /m \"*.js\" /c \"cmd /c npx esbuild @file --minify --allow-overwrite --outfile=@file\"", | ||
"mini": "run-script-os", | ||
"isnode18": "check-node-version --node 18", | ||
"install:esmock": "cd .. && npm install", | ||
"install:test-ava": "cd tests-ava && npm install", | ||
"install:test-uvu": "cd tests-uvu && npm install", | ||
"install:test-node": "cd tests-node && npm install", | ||
"install:test-nodets": "cd tests-nodets && npm install", | ||
"install:all": "npm install && npm-run-all install:test*", | ||
"test:test-ava": "cd tests-ava && npm test", | ||
"test:test-uvu": "cd tests-uvu && npm test", | ||
"test:test-node": "npm run isnode18 && cd tests-node && npm test || true", | ||
"test:test-nodets": "npm run isnode18 && cd tests-nodets && npm test || true", | ||
"test:all": "npm-run-all test:test*", | ||
"test:all-ci": "npm run mini && npm run test:all" | ||
} | ||
} |
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,35 @@ | ||
export {default, load, resolve, getSource} from '../src/esmockLoader.js'; | ||
|
||
// this file is used in tandem with two other things, | ||
// | ||
// 1. a "main" definition in ./package.json, | ||
// ``` | ||
// { | ||
// "main": "tests.esmock.export.js" | ||
// } | ||
// ``` | ||
// | ||
// 2. an "esmock" definition in child ./tests-ava/package.json | ||
// ``` | ||
// { | ||
// "dependencies": { | ||
// "esmock": "file:.." | ||
// } | ||
// } | ||
// ``` | ||
// | ||
// together, these allow child folder tests to, | ||
// * import "esmock" rather than "../../src/esmock.js" | ||
// * use "--loader=esmock" rather than "../../src/esmockLoader.js" | ||
// | ||
// Previously, there existed only one test folder and package.json, | ||
// and during that time the package.json only needed to define | ||
// the esmock dependency as a local file eg "esmock": "file:.." | ||
// | ||
// When subdirectories were introduced, "esmock": "file:../.." did not | ||
// work with "--loader=esmock". The loader ignored the longer path and | ||
// threw an error message, creating need for this file. | ||
// | ||
// Error [ERR_MODULE_NOT_FOUND]: Cannot find package \ | ||
// '/root/esmock/tests/tests-ava/node_modules/esmock/' \ | ||
// imported from /root/esmock/tests/tests-ava/ |
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,19 @@ | ||
{ | ||
"type": "module", | ||
"description": "esmock unit tests, ava", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/iambumblehead/esmock.git" | ||
}, | ||
"dependencies": { | ||
"ava": "^4.3.1", | ||
"esmock": "file:..", | ||
"sinon": "file:../node_modules/sinon", | ||
"eslint": "file:../node_modules/eslint", | ||
"form-urlencoded": "file:../node_modules/form-urlencoded", | ||
"babelGeneratedDoubleDefault": "file:../local/babelGeneratedDoubleDefault" | ||
}, | ||
"scripts": { | ||
"test": "ava --node-arguments=\"--loader=esmock\"" | ||
} | ||
} |
6 changes: 4 additions & 2 deletions
6
tests/tests-ava/esmock.ava.only.spec.js → tests/tests-ava/spec/esmock.ava.only.spec.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
Oops, something went wrong.