@mediatool/frontend-tools 1.2.3 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mtft.cjs +31 -18
- package/lib/test/dom-shims.cjs +14 -0
- package/lib/test/index.js +31 -14
- package/package.json +3 -6
- package/lib/test/setup-mocha.cjs +0 -14
package/dist/mtft.cjs
CHANGED
|
@@ -6,12 +6,8 @@ var vite = require('vite');
|
|
|
6
6
|
var promises = require('fs/promises');
|
|
7
7
|
var path = require('path');
|
|
8
8
|
var ramda = require('ramda');
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
|
-
|
|
14
|
-
var Mocha__default = /*#__PURE__*/_interopDefaultLegacy(Mocha);
|
|
9
|
+
var module$1 = require('module');
|
|
10
|
+
var child_process = require('child_process');
|
|
15
11
|
|
|
16
12
|
async function getModuleContext () {
|
|
17
13
|
const location = process.cwd();
|
|
@@ -70,6 +66,10 @@ function build (type) {
|
|
|
70
66
|
return fn()
|
|
71
67
|
}
|
|
72
68
|
|
|
69
|
+
const require$1 = module$1.createRequire((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('mtft.cjs', document.baseURI).href)));
|
|
70
|
+
const mochaCliPath = require$1.resolve('mocha/lib/cli/cli.js');
|
|
71
|
+
const domShimsPath = require$1.resolve('@mediatool/frontend-tools/lib/test/dom-shims.cjs');
|
|
72
|
+
|
|
73
73
|
const extensions = '{js,jsx,ts,tsx}';
|
|
74
74
|
const types = {
|
|
75
75
|
all: `./{,!(node_modules)/**}/**/*-test.${extensions}`,
|
|
@@ -77,20 +77,33 @@ const types = {
|
|
|
77
77
|
it: `./{,!(node_modules)/**}/test/it/**/*-test.${extensions}`,
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
async function test (typeOrSpec
|
|
81
|
-
const { require = [] } = options;
|
|
80
|
+
async function test (typeOrSpec) {
|
|
82
81
|
const spec = types[typeOrSpec] || typeOrSpec;
|
|
83
82
|
|
|
84
|
-
const
|
|
85
|
-
'
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
83
|
+
const args = [
|
|
84
|
+
'--loader=tsx',
|
|
85
|
+
mochaCliPath,
|
|
86
|
+
spec,
|
|
87
|
+
'--require',
|
|
88
|
+
'global-jsdom/register',
|
|
89
|
+
'--require',
|
|
90
|
+
domShimsPath,
|
|
91
|
+
];
|
|
92
|
+
|
|
93
|
+
const mochaProcess = child_process.spawn(process.execPath, args, { stdio: 'inherit' });
|
|
94
|
+
|
|
95
|
+
mochaProcess.on('exit', (code, signal) => {
|
|
96
|
+
process.on('exit', () => {
|
|
97
|
+
if (signal) {
|
|
98
|
+
process.kill(process.pid, signal);
|
|
99
|
+
} else {
|
|
100
|
+
process.exit(code);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
process.on('SIGINT', () => {
|
|
105
|
+
mochaProcess.kill('SIGINT');
|
|
106
|
+
});
|
|
94
107
|
}
|
|
95
108
|
|
|
96
109
|
const program = new commander.Command();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
if (typeof window !== 'undefined' && !window.matchMedia) {
|
|
2
|
+
window.matchMedia = function(query) {
|
|
3
|
+
return {
|
|
4
|
+
matches: false,
|
|
5
|
+
media: query,
|
|
6
|
+
onchange: null,
|
|
7
|
+
addListener: function () {},
|
|
8
|
+
removeListener: function() {},
|
|
9
|
+
addEventListener: function() {},
|
|
10
|
+
removeEventListener: function() {},
|
|
11
|
+
dispatchEvent: function() { return true; }
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
}
|
package/lib/test/index.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { createRequire } from 'module'
|
|
2
|
+
import { spawn } from 'child_process'
|
|
3
|
+
|
|
4
|
+
const require = createRequire(import.meta.url)
|
|
5
|
+
const mochaCliPath = require.resolve('mocha/lib/cli/cli.js')
|
|
6
|
+
const domShimsPath = require.resolve('@mediatool/frontend-tools/lib/test/dom-shims.cjs')
|
|
3
7
|
|
|
4
8
|
const extensions = '{js,jsx,ts,tsx}'
|
|
5
9
|
const types = {
|
|
@@ -8,18 +12,31 @@ const types = {
|
|
|
8
12
|
it: `./{,!(node_modules)/**}/test/it/**/*-test.${extensions}`,
|
|
9
13
|
}
|
|
10
14
|
|
|
11
|
-
export default async function test (typeOrSpec
|
|
12
|
-
const { require = [] } = options
|
|
15
|
+
export default async function test (typeOrSpec) {
|
|
13
16
|
const spec = types[typeOrSpec] || typeOrSpec
|
|
14
17
|
|
|
15
|
-
const
|
|
16
|
-
'
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
const args = [
|
|
19
|
+
'--loader=tsx',
|
|
20
|
+
mochaCliPath,
|
|
21
|
+
spec,
|
|
22
|
+
'--require',
|
|
23
|
+
'global-jsdom/register',
|
|
24
|
+
'--require',
|
|
25
|
+
domShimsPath,
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
const mochaProcess = spawn(process.execPath, args, { stdio: 'inherit' })
|
|
29
|
+
|
|
30
|
+
mochaProcess.on('exit', (code, signal) => {
|
|
31
|
+
process.on('exit', () => {
|
|
32
|
+
if (signal) {
|
|
33
|
+
process.kill(process.pid, signal)
|
|
34
|
+
} else {
|
|
35
|
+
process.exit(code)
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
process.on('SIGINT', () => {
|
|
40
|
+
mochaProcess.kill('SIGINT')
|
|
41
|
+
})
|
|
25
42
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mediatool/frontend-tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Common configs and tooling for bundling, testing, linting frontend modules",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
".": "./dist/utils.js",
|
|
10
10
|
"./assertions": "./dist/assertions.js",
|
|
11
11
|
"./react": "./dist/react.js",
|
|
12
|
-
"./lib/test/
|
|
12
|
+
"./lib/test/dom-shims.cjs": "./lib/test/dom-shims.cjs"
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
15
|
"build": "rm -rf dist && rollup -c rollup.config.js",
|
|
@@ -20,11 +20,7 @@
|
|
|
20
20
|
"mtft": "./dist/mtft.cjs"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@babel/core": "^7.20.2",
|
|
24
|
-
"@babel/preset-env": "^7.20.2",
|
|
25
23
|
"@babel/preset-react": "^7.18.6",
|
|
26
|
-
"@babel/preset-typescript": "^7.18.6",
|
|
27
|
-
"@babel/register": "^7.18.9",
|
|
28
24
|
"@mediatool/eslint-config-mediatool": "^1.1.13",
|
|
29
25
|
"@testing-library/react": "^13.4.0",
|
|
30
26
|
"@testing-library/user-event": "^14.4.3",
|
|
@@ -36,6 +32,7 @@
|
|
|
36
32
|
"global-jsdom": "^8.6.0",
|
|
37
33
|
"jsdom": "^20.0.2",
|
|
38
34
|
"mocha": "^10.1.0",
|
|
35
|
+
"tsx": "^3.12.7",
|
|
39
36
|
"vite": "^3.2.4"
|
|
40
37
|
},
|
|
41
38
|
"peerDependencies": {
|
package/lib/test/setup-mocha.cjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/* eslint-env es6 */
|
|
2
|
-
/* eslint-disable import/no-extraneous-dependencies */
|
|
3
|
-
const babel = require('@babel/register').default
|
|
4
|
-
const jsdom = require('global-jsdom')
|
|
5
|
-
|
|
6
|
-
babel({
|
|
7
|
-
presets: [
|
|
8
|
-
'@babel/preset-env',
|
|
9
|
-
'@babel/preset-react',
|
|
10
|
-
'@babel/preset-typescript',
|
|
11
|
-
],
|
|
12
|
-
extensions: [ '.ts', '.tsx', '.js', '.jsx' ],
|
|
13
|
-
})
|
|
14
|
-
jsdom()
|