@rindo/core 2.16.1 → 2.17.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/cli/config-flags.d.ts +102 -0
- package/cli/index.cjs +690 -223
- package/cli/index.d.ts +2 -1
- package/cli/index.js +690 -223
- package/cli/package.json +1 -1
- package/compiler/package.json +1 -1
- package/compiler/rindo.js +856 -289
- package/compiler/rindo.min.js +2 -2
- package/dependencies.json +1 -1
- package/dev-server/client/index.js +1 -1
- package/dev-server/client/package.json +1 -1
- package/dev-server/connector.html +2 -2
- package/dev-server/index.js +1 -1
- package/dev-server/package.json +1 -1
- package/dev-server/server-process.js +2 -2
- package/internal/app-data/package.json +1 -1
- package/internal/client/css-shim.js +1 -1
- package/internal/client/dom.js +1 -1
- package/internal/client/index.js +11 -6
- package/internal/client/package.json +1 -1
- package/internal/client/patch-browser.js +1 -1
- package/internal/client/patch-esm.js +1 -1
- package/internal/client/shadow-css.js +1 -1
- package/internal/hydrate/index.js +2 -2
- package/internal/hydrate/package.json +1 -1
- package/internal/package.json +1 -1
- package/internal/rindo-private.d.ts +6 -2
- package/internal/rindo-public-compiler.d.ts +67 -48
- package/internal/testing/index.js +1 -1
- package/internal/testing/package.json +1 -1
- package/mock-doc/index.cjs +140 -5
- package/mock-doc/index.d.ts +76 -1
- package/mock-doc/index.js +140 -5
- package/mock-doc/package.json +1 -1
- package/package.json +5 -3
- package/screenshot/package.json +1 -1
- package/sys/node/index.js +325 -314
- package/sys/node/package.json +1 -1
- package/sys/node/worker.js +1 -1
- package/testing/index.d.ts +1 -1
- package/testing/index.js +124 -69
- package/testing/jest/jest-config.d.ts +1 -1
- package/testing/jest/jest-runner.d.ts +3 -2
- package/testing/jest/jest-screenshot.d.ts +1 -1
- package/testing/mocks.d.ts +48 -3
- package/testing/package.json +1 -1
- package/testing/puppeteer/puppeteer-browser.d.ts +2 -2
- package/testing/testing-utils.d.ts +74 -2
- package/testing/testing.d.ts +2 -2
package/sys/node/package.json
CHANGED
package/sys/node/worker.js
CHANGED
package/testing/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { createTesting } from './testing';
|
|
|
3
3
|
export { createTestRunner } from './jest/jest-runner';
|
|
4
4
|
export { jestPreprocessor } from './jest/jest-preprocessor';
|
|
5
5
|
export { jestSetupTestFramework } from './jest/jest-setup-test-framework';
|
|
6
|
-
export { mockBuildCtx, mockConfig, mockCompilerCtx, mockDocument, mockLogger,
|
|
6
|
+
export { mockBuildCtx, mockConfig, mockCompilerCtx, mockDocument, mockLoadConfigInit, mockValidatedConfig, mockLogger, mockCompilerSystem, mockWindow, mockModule, } from './mocks';
|
|
7
7
|
export { MockHeaders, MockRequest, MockRequestInit, MockRequestInfo, MockResponse, MockResponseInit, mockFetch, } from './mock-fetch';
|
|
8
8
|
export { newSpecPage } from './spec-page';
|
|
9
9
|
export { shuffleArray } from './testing-utils';
|
package/testing/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
Rindo Testing v2.
|
|
2
|
+
Rindo Testing v2.17.1 | MIT Licensed | https://rindojs.web.app
|
|
3
3
|
*/
|
|
4
4
|
function _lazyRequire(e) {
|
|
5
5
|
return new Proxy({}, {
|
|
@@ -476,7 +476,11 @@ function mockConfig(e) {
|
|
|
476
476
|
nodeResolve: {
|
|
477
477
|
customResolveOptions: {}
|
|
478
478
|
},
|
|
479
|
-
sourceMap: !0
|
|
479
|
+
sourceMap: !0,
|
|
480
|
+
rollupPlugins: {
|
|
481
|
+
before: [],
|
|
482
|
+
after: []
|
|
483
|
+
}
|
|
480
484
|
};
|
|
481
485
|
}
|
|
482
486
|
|
|
@@ -499,7 +503,7 @@ function mockCompilerCtx(e) {
|
|
|
499
503
|
compilerOptions: null,
|
|
500
504
|
cache: null,
|
|
501
505
|
cssModuleImports: new Map,
|
|
502
|
-
events:
|
|
506
|
+
events: buildEvents(),
|
|
503
507
|
fs: null,
|
|
504
508
|
hasSuccessfulBuild: !1,
|
|
505
509
|
isActivelyBuilding: !1,
|
|
@@ -813,6 +817,10 @@ function mockCompilerCtx(e) {
|
|
|
813
817
|
}), t;
|
|
814
818
|
}
|
|
815
819
|
|
|
820
|
+
function mockLogger() {
|
|
821
|
+
return new TestingLogger;
|
|
822
|
+
}
|
|
823
|
+
|
|
816
824
|
function findRootComponent(e, t) {
|
|
817
825
|
if (null != t) {
|
|
818
826
|
const r = t.children, s = r.length;
|
|
@@ -2087,7 +2095,46 @@ const MAX_FAILED = 100, ONE_DAY = 864e5, ONE_WEEK = 7 * ONE_DAY, EXP_STORAGE_KEY
|
|
|
2087
2095
|
posix: null
|
|
2088
2096
|
}).posix = posix, pathBrowserify = posix;
|
|
2089
2097
|
|
|
2090
|
-
const
|
|
2098
|
+
const buildEvents = () => {
|
|
2099
|
+
const e = [], t = t => {
|
|
2100
|
+
const r = e.findIndex((e => e.callback === t));
|
|
2101
|
+
return r > -1 && (e.splice(r, 1), !0);
|
|
2102
|
+
};
|
|
2103
|
+
return {
|
|
2104
|
+
emit: (t, r) => {
|
|
2105
|
+
const s = t.toLowerCase().trim(), n = e.slice();
|
|
2106
|
+
for (const e of n) if (null == e.eventName) try {
|
|
2107
|
+
e.callback(t, r);
|
|
2108
|
+
} catch (e) {
|
|
2109
|
+
console.error(e);
|
|
2110
|
+
} else if (e.eventName === s) try {
|
|
2111
|
+
e.callback(r);
|
|
2112
|
+
} catch (e) {
|
|
2113
|
+
console.error(e);
|
|
2114
|
+
}
|
|
2115
|
+
},
|
|
2116
|
+
on: (r, s) => {
|
|
2117
|
+
if ("function" == typeof r) {
|
|
2118
|
+
const s = null, n = r;
|
|
2119
|
+
return e.push({
|
|
2120
|
+
eventName: s,
|
|
2121
|
+
callback: n
|
|
2122
|
+
}), () => t(n);
|
|
2123
|
+
}
|
|
2124
|
+
if ("string" == typeof r && "function" == typeof s) {
|
|
2125
|
+
const n = r.toLowerCase().trim(), o = s;
|
|
2126
|
+
return e.push({
|
|
2127
|
+
eventName: n,
|
|
2128
|
+
callback: o
|
|
2129
|
+
}), () => t(o);
|
|
2130
|
+
}
|
|
2131
|
+
return () => !1;
|
|
2132
|
+
},
|
|
2133
|
+
unsubscribeAll: () => {
|
|
2134
|
+
e.length = 0;
|
|
2135
|
+
}
|
|
2136
|
+
};
|
|
2137
|
+
}, IS_NODE_ENV = !("undefined" == typeof global || "function" != typeof require || !global.process || "string" != typeof __filename || global.origin && "string" == typeof global.origin);
|
|
2091
2138
|
|
|
2092
2139
|
IS_NODE_ENV && process.platform;
|
|
2093
2140
|
|
|
@@ -2119,15 +2166,14 @@ const YELLOW = "#f39c12", RED = "#c0392b", BLUE = "#3498db", COMMON_DIR_MODULE_E
|
|
|
2119
2166
|
let o = s.shift();
|
|
2120
2167
|
o.startsWith("@") && (o += "/" + s.shift());
|
|
2121
2168
|
const i = s.join("/");
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
}
|
|
2130
|
-
return e.getRemoteModuleUrl({
|
|
2169
|
+
return "@rindo/core" === o ? ((e, t) => {
|
|
2170
|
+
let r = (t = normalizePath(t)).split("/");
|
|
2171
|
+
const s = r.lastIndexOf("node_modules");
|
|
2172
|
+
s > -1 && s < r.length - 1 && (r = r.slice(s + 1), r = r[0].startsWith("@") ? r.slice(2) : r.slice(1),
|
|
2173
|
+
t = r.join("/"));
|
|
2174
|
+
const n = new URL("../", e).href;
|
|
2175
|
+
return new URL("./" + t, n).href;
|
|
2176
|
+
})(e.getCompilerExecutingPath(), i) : e.getRemoteModuleUrl({
|
|
2131
2177
|
moduleId: o,
|
|
2132
2178
|
version: t.get(o),
|
|
2133
2179
|
path: i
|
|
@@ -2139,7 +2185,7 @@ const YELLOW = "#f39c12", RED = "#c0392b", BLUE = "#3498db", COMMON_DIR_MODULE_E
|
|
|
2139
2185
|
const r = e.split("/"), s = r[r.length - 2], n = r[r.length - 1];
|
|
2140
2186
|
return !("node_modules" !== s || !isCommonDirModuleFile(n));
|
|
2141
2187
|
})(n) || known404Urls.has(s) || (e => knownUrlSkips.some((t => e.endsWith(t))))(s))) try {
|
|
2142
|
-
const o = await ((e, t, r) =>
|
|
2188
|
+
const o = await ((e, t, r) => e && isFunction(e.fetch) ? e.fetch(t, r) : fetch(t, r))(e, s);
|
|
2143
2189
|
if (o) {
|
|
2144
2190
|
if (o.ok) {
|
|
2145
2191
|
const i = await o.clone().text();
|
|
@@ -2852,46 +2898,7 @@ const createSystem = e => {
|
|
|
2852
2898
|
})(t, e)));
|
|
2853
2899
|
}
|
|
2854
2900
|
};
|
|
2855
|
-
})(), r = new Map, s = new Set, n = e => s.add(e), o = e => s.delete(e), i = (
|
|
2856
|
-
const e = [], t = t => {
|
|
2857
|
-
const r = e.findIndex((e => e.callback === t));
|
|
2858
|
-
return r > -1 && (e.splice(r, 1), !0);
|
|
2859
|
-
};
|
|
2860
|
-
return {
|
|
2861
|
-
emit: (t, r) => {
|
|
2862
|
-
const s = t.toLowerCase().trim(), n = e.slice();
|
|
2863
|
-
for (const e of n) if (null == e.eventName) try {
|
|
2864
|
-
e.callback(t, r);
|
|
2865
|
-
} catch (e) {
|
|
2866
|
-
console.error(e);
|
|
2867
|
-
} else if (e.eventName === s) try {
|
|
2868
|
-
e.callback(r);
|
|
2869
|
-
} catch (e) {
|
|
2870
|
-
console.error(e);
|
|
2871
|
-
}
|
|
2872
|
-
},
|
|
2873
|
-
on: (r, s) => {
|
|
2874
|
-
if ("function" == typeof r) {
|
|
2875
|
-
const s = null, n = r;
|
|
2876
|
-
return e.push({
|
|
2877
|
-
eventName: s,
|
|
2878
|
-
callback: n
|
|
2879
|
-
}), () => t(n);
|
|
2880
|
-
}
|
|
2881
|
-
if ("string" == typeof r && "function" == typeof s) {
|
|
2882
|
-
const n = r.toLowerCase().trim(), o = s;
|
|
2883
|
-
return e.push({
|
|
2884
|
-
eventName: n,
|
|
2885
|
-
callback: o
|
|
2886
|
-
}), () => t(o);
|
|
2887
|
-
}
|
|
2888
|
-
return () => !1;
|
|
2889
|
-
},
|
|
2890
|
-
unsubscribeAll: () => {
|
|
2891
|
-
e.length = 0;
|
|
2892
|
-
}
|
|
2893
|
-
};
|
|
2894
|
-
})(), a = IS_BROWSER_ENV && navigator.hardwareConcurrency || 1, l = e => {
|
|
2901
|
+
})(), r = new Map, s = new Set, n = e => s.add(e), o = e => s.delete(e), i = buildEvents(), a = IS_BROWSER_ENV && navigator.hardwareConcurrency || 1, l = e => {
|
|
2895
2902
|
if ("/" === e || "" === e) return "/";
|
|
2896
2903
|
const t = path$2.dirname(e), r = path$2.basename(e);
|
|
2897
2904
|
return t.endsWith("/") ? normalizePath(`${t}${r}`) : normalizePath(`${t}/${r}`);
|
|
@@ -3037,7 +3044,7 @@ const createSystem = e => {
|
|
|
3037
3044
|
u("/");
|
|
3038
3045
|
const D = {
|
|
3039
3046
|
name: "in-memory",
|
|
3040
|
-
version: "2.
|
|
3047
|
+
version: "2.17.1",
|
|
3041
3048
|
events: i,
|
|
3042
3049
|
access: async e => c(e),
|
|
3043
3050
|
accessSync: c,
|
|
@@ -3325,7 +3332,8 @@ const createSystem = e => {
|
|
|
3325
3332
|
r.readDirSync = s(r.readDirSync), r.stat = s(r.stat), r.statSync = s(r.statSync),
|
|
3326
3333
|
r.copyFile = n(r.copyFile), r.createDir = n(r.createDir), r.createDirSync = n(r.createDirSync),
|
|
3327
3334
|
r.removeFile = n(r.removeFile), r.removeFileSync = n(r.removeFileSync), r.writeFile = n(r.writeFile),
|
|
3328
|
-
r.writeFileSync = n(r.writeFileSync),
|
|
3335
|
+
r.writeFileSync = n(r.writeFileSync), r.getCompilerExecutingPath = () => "bin/rindo.js",
|
|
3336
|
+
Object.defineProperties(r, {
|
|
3329
3337
|
diskReads: {
|
|
3330
3338
|
get: () => e,
|
|
3331
3339
|
set(t) {
|
|
@@ -3793,8 +3801,8 @@ exports.createJestPuppeteerEnvironment = function createJestPuppeteerEnvironment
|
|
|
3793
3801
|
}, exports.createTesting = async e => {
|
|
3794
3802
|
e = function t(e) {
|
|
3795
3803
|
return e.buildEs5 = !1, e.devMode = !0, e.minifyCss = !1, e.minifyJs = !1, e.hashFileNames = !1,
|
|
3796
|
-
e.validateTypes = !1, e._isTesting = !0, e.buildDist = !0, e.flags = e.flags
|
|
3797
|
-
e.
|
|
3804
|
+
e.validateTypes = !1, e._isTesting = !0, e.buildDist = !0, e.flags.serve = !1, e.flags.open = !1,
|
|
3805
|
+
e.outputTargets.forEach((e => {
|
|
3798
3806
|
"www" === e.type && (e.serviceWorker = null);
|
|
3799
3807
|
})), e.flags.args.includes("--watchAll") && (e.watch = !0), e;
|
|
3800
3808
|
}(e);
|
|
@@ -3928,12 +3936,57 @@ exports.createJestPuppeteerEnvironment = function createJestPuppeteerEnvironment
|
|
|
3928
3936
|
}
|
|
3929
3937
|
}, exports.mockBuildCtx = function mockBuildCtx(e, t) {
|
|
3930
3938
|
return e || (e = mockConfig()), t || (t = mockCompilerCtx(e)), new BuildContext(e, t);
|
|
3931
|
-
}, exports.mockCompilerCtx = mockCompilerCtx, exports.
|
|
3932
|
-
return new index_cjs.MockWindow(e).document;
|
|
3933
|
-
}, exports.mockFetch = mockFetch, exports.mockLogger = function mockLogger() {
|
|
3934
|
-
return new TestingLogger;
|
|
3935
|
-
}, exports.mockRindoSystem = function mockRindoSystem() {
|
|
3939
|
+
}, exports.mockCompilerCtx = mockCompilerCtx, exports.mockCompilerSystem = function mockCompilerSystem() {
|
|
3936
3940
|
return createTestingSystem();
|
|
3941
|
+
}, exports.mockConfig = mockConfig, exports.mockDocument = function mockDocument(e = null) {
|
|
3942
|
+
return new index_cjs.MockWindow(e).document;
|
|
3943
|
+
}, exports.mockFetch = mockFetch, exports.mockLoadConfigInit = e => ({
|
|
3944
|
+
config: {},
|
|
3945
|
+
configPath: void 0,
|
|
3946
|
+
initTsConfig: !0,
|
|
3947
|
+
logger: void 0,
|
|
3948
|
+
sys: void 0,
|
|
3949
|
+
...e
|
|
3950
|
+
}), exports.mockLogger = mockLogger, exports.mockModule = (e = {}) => ({
|
|
3951
|
+
cmps: [],
|
|
3952
|
+
coreRuntimeApis: [],
|
|
3953
|
+
collectionName: "",
|
|
3954
|
+
dtsFilePath: "",
|
|
3955
|
+
excludeFromCollection: !1,
|
|
3956
|
+
externalImports: [],
|
|
3957
|
+
htmlAttrNames: [],
|
|
3958
|
+
htmlTagNames: [],
|
|
3959
|
+
htmlParts: [],
|
|
3960
|
+
isCollectionDependency: !1,
|
|
3961
|
+
isLegacy: !1,
|
|
3962
|
+
jsFilePath: "",
|
|
3963
|
+
localImports: [],
|
|
3964
|
+
originalImports: [],
|
|
3965
|
+
originalCollectionComponentPath: "",
|
|
3966
|
+
potentialCmpRefs: [],
|
|
3967
|
+
sourceFilePath: "",
|
|
3968
|
+
staticSourceFile: "",
|
|
3969
|
+
staticSourceFileText: "",
|
|
3970
|
+
sourceMapPath: "",
|
|
3971
|
+
sourceMapFileText: "",
|
|
3972
|
+
hasVdomAttribute: !1,
|
|
3973
|
+
hasVdomClass: !1,
|
|
3974
|
+
hasVdomFunctional: !1,
|
|
3975
|
+
hasVdomKey: !1,
|
|
3976
|
+
hasVdomListener: !1,
|
|
3977
|
+
hasVdomPropOrAttr: !1,
|
|
3978
|
+
hasVdomRef: !1,
|
|
3979
|
+
hasVdomRender: !1,
|
|
3980
|
+
hasVdomStyle: !1,
|
|
3981
|
+
hasVdomText: !1,
|
|
3982
|
+
hasVdomXlink: !1,
|
|
3983
|
+
...e
|
|
3984
|
+
}), exports.mockValidatedConfig = function mockValidatedConfig(e) {
|
|
3985
|
+
return {
|
|
3986
|
+
...mockConfig(e),
|
|
3987
|
+
flags: {},
|
|
3988
|
+
logger: mockLogger()
|
|
3989
|
+
};
|
|
3937
3990
|
}, exports.mockWindow = function mockWindow(e = null) {
|
|
3938
3991
|
return new index_cjs.MockWindow(e);
|
|
3939
3992
|
}, exports.newE2EPage = async function newE2EPage(e = {}) {
|
|
@@ -4037,26 +4090,28 @@ exports.createJestPuppeteerEnvironment = function createJestPuppeteerEnvironment
|
|
|
4037
4090
|
};
|
|
4038
4091
|
const o = !0 === e.failOnConsoleError, i = !0 === e.failOnNetworkError;
|
|
4039
4092
|
t.on("console", (e => {
|
|
4040
|
-
"error" === e.type() && (r.push({
|
|
4093
|
+
if ("error" === e.type() && (r.push({
|
|
4041
4094
|
type: "error",
|
|
4042
4095
|
message: e.text(),
|
|
4043
4096
|
location: e.location().url
|
|
4044
|
-
}), o
|
|
4097
|
+
}), o)) throw new Error(serializeConsoleMessage(e));
|
|
4098
|
+
!function t(e) {
|
|
4045
4099
|
const t = serializeConsoleMessage(e), r = e.type(), s = "warning" === r ? "warn" : r;
|
|
4046
4100
|
"debug" !== s && ("function" == typeof console[s] ? console[s](t) : console.log(r, t));
|
|
4047
4101
|
}(e);
|
|
4048
4102
|
})), t.on("pageerror", (e => {
|
|
4049
|
-
r.push({
|
|
4103
|
+
throw r.push({
|
|
4050
4104
|
type: "pageerror",
|
|
4051
4105
|
message: e.message,
|
|
4052
4106
|
location: e.stack
|
|
4053
|
-
}),
|
|
4107
|
+
}), e;
|
|
4054
4108
|
})), t.on("requestfailed", (e => {
|
|
4055
|
-
r.push({
|
|
4109
|
+
if (r.push({
|
|
4056
4110
|
type: "requestfailed",
|
|
4057
4111
|
message: e.failure().errorText,
|
|
4058
4112
|
location: e.url()
|
|
4059
|
-
}), i
|
|
4113
|
+
}), i) throw new Error(e.failure().errorText);
|
|
4114
|
+
console.error("requestfailed", e.url());
|
|
4060
4115
|
})), "string" == typeof e.html ? await e2eSetContent(t, e.html, {
|
|
4061
4116
|
waitUntil: e.waitUntil
|
|
4062
4117
|
}) : "string" == typeof e.url ? await e2eGoTo(t, e.url, {
|
|
@@ -5,7 +5,7 @@ import type { Config } from '@jest/types';
|
|
|
5
5
|
* @param config the Rindo config to use while generating Jest CLI arguments
|
|
6
6
|
* @returns the arguments to pass to the Jest CLI, wrapped in an object
|
|
7
7
|
*/
|
|
8
|
-
export declare function buildJestArgv(config: d.
|
|
8
|
+
export declare function buildJestArgv(config: d.ValidatedConfig): Config.Argv;
|
|
9
9
|
/**
|
|
10
10
|
* Generate a Jest run configuration to be used as a part of the `argv` passed to the Jest CLI when it is invoked
|
|
11
11
|
* programmatically
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type * as d from '@rindo/core/internal';
|
|
2
|
-
|
|
2
|
+
import type { ConfigFlags } from '../../cli/config-flags';
|
|
3
|
+
export declare function runJest(config: d.ValidatedConfig, env: d.E2EProcessEnv): Promise<boolean>;
|
|
3
4
|
/**
|
|
4
5
|
* Creates a Rindo test runner
|
|
5
6
|
* @returns the test runner
|
|
6
7
|
*/
|
|
7
8
|
export declare function createTestRunner(): any;
|
|
8
9
|
export declare function includeTestFile(testPath: string, env: d.E2EProcessEnv): boolean;
|
|
9
|
-
export declare function getEmulateConfigs(testing: d.TestingConfig, flags:
|
|
10
|
+
export declare function getEmulateConfigs(testing: d.TestingConfig, flags: ConfigFlags): d.EmulateConfig[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type * as d from '@rindo/core/internal';
|
|
2
|
-
export declare function runJestScreenshot(config: d.
|
|
2
|
+
export declare function runJestScreenshot(config: d.ValidatedConfig, env: d.E2EProcessEnv): Promise<boolean>;
|
package/testing/mocks.d.ts
CHANGED
|
@@ -1,10 +1,55 @@
|
|
|
1
|
-
import type { BuildCtx, Cache, CompilerCtx, CompilerSystem, Config } from '@rindo/core/internal';
|
|
1
|
+
import type { BuildCtx, Cache, CompilerCtx, CompilerSystem, Config, LoadConfigInit, ValidatedConfig, Module, UnvalidatedConfig } from '@rindo/core/internal';
|
|
2
|
+
import { TestingSystem } from './testing-sys';
|
|
2
3
|
import { TestingLogger } from './testing-logger';
|
|
3
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Creates a mock instance of an internal, validated Rindo configuration object
|
|
6
|
+
* @param sys an optional compiler system to associate with the config. If one is not provided, one will be created for
|
|
7
|
+
* the caller
|
|
8
|
+
* @returns the mock Rindo configuration
|
|
9
|
+
*/
|
|
10
|
+
export declare function mockValidatedConfig(sys?: CompilerSystem): ValidatedConfig;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a mock instance of a Rindo configuration entity. The mocked configuration has no guarantees around the
|
|
13
|
+
* types/validity of its data.
|
|
14
|
+
* @param sys an optional compiler system to associate with the config. If one is not provided, one will be created for
|
|
15
|
+
* the caller
|
|
16
|
+
* @returns the mock Rindo configuration
|
|
17
|
+
*/
|
|
18
|
+
export declare function mockConfig(sys?: CompilerSystem): UnvalidatedConfig;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a configuration object used to bootstrap a Rindo task invocation
|
|
21
|
+
*
|
|
22
|
+
* Several fields are intentionally undefined for this entity. While it would be trivial to stub them out, this mock
|
|
23
|
+
* generation function operates under the assumption that entities like loggers and compiler system abstractions will
|
|
24
|
+
* be shared by multiple entities in a test suite, who should provide those entities to this function
|
|
25
|
+
*
|
|
26
|
+
* @param overrides the properties on the default entity to manually override
|
|
27
|
+
* @returns the default configuration initialization object, with any overrides applied
|
|
28
|
+
*/
|
|
29
|
+
export declare const mockLoadConfigInit: (overrides?: Partial<LoadConfigInit>) => LoadConfigInit;
|
|
4
30
|
export declare function mockCompilerCtx(config?: Config): CompilerCtx;
|
|
5
31
|
export declare function mockBuildCtx(config?: Config, compilerCtx?: CompilerCtx): BuildCtx;
|
|
6
32
|
export declare function mockCache(config?: Config, compilerCtx?: CompilerCtx): Cache;
|
|
7
33
|
export declare function mockLogger(): TestingLogger;
|
|
8
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Create a {@link CompilerSystem} entity for testing the compiler.
|
|
36
|
+
*
|
|
37
|
+
* This function acts as a thin wrapper around a {@link TestingSystem} entity creation. It exists to provide a logical
|
|
38
|
+
* place in the codebase where we might expect Rindo engineers to reach for when attempting to mock a
|
|
39
|
+
* {@link CompilerSystem} base type. Should there prove to be usage of both this function and the one it wraps,
|
|
40
|
+
* reconsider if this wrapper is necessary.
|
|
41
|
+
*
|
|
42
|
+
* @returns a System instance for testing purposes.
|
|
43
|
+
*/
|
|
44
|
+
export declare function mockCompilerSystem(): TestingSystem;
|
|
9
45
|
export declare function mockDocument(html?: string): Document;
|
|
10
46
|
export declare function mockWindow(html?: string): Window;
|
|
47
|
+
/**
|
|
48
|
+
* This gives you a mock Module, an interface which is the internal compiler
|
|
49
|
+
* representation of a module. It includes a bunch of information necessary for
|
|
50
|
+
* compilation, this mock basically sets sane defaults for all those values.
|
|
51
|
+
*
|
|
52
|
+
* @param mod is an override module that you can supply to set particular values
|
|
53
|
+
* @returns a module object ready to use in tests!
|
|
54
|
+
*/
|
|
55
|
+
export declare const mockModule: (mod?: Partial<Module>) => Module;
|
package/testing/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ValidatedConfig } from '@rindo/core/internal';
|
|
2
2
|
import type * as puppeteer from 'puppeteer';
|
|
3
|
-
export declare function startPuppeteerBrowser(config:
|
|
3
|
+
export declare function startPuppeteerBrowser(config: ValidatedConfig): Promise<puppeteer.Browser>;
|
|
4
4
|
export declare function connectBrowser(): Promise<any>;
|
|
5
5
|
export declare function disconnectBrowser(browser: puppeteer.Browser): Promise<void>;
|
|
6
6
|
export declare function newBrowserPage(browser: puppeteer.Browser): Promise<puppeteer.Page>;
|
|
@@ -1,6 +1,78 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
1
2
|
import type * as d from '@rindo/core/internal';
|
|
2
3
|
export declare function shuffleArray(array: any[]): any[];
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Testing utility to validate the existence of some provided file paths using a specific file system
|
|
6
|
+
*
|
|
7
|
+
* @param fs the file system to use to validate the existence of some files
|
|
8
|
+
* @param filePaths the paths to validate
|
|
9
|
+
* @throws when one or more of the provided file paths cannot be found
|
|
10
|
+
*/
|
|
11
|
+
export declare function expectFilesExist(fs: d.InMemoryFileSystem, filePaths: string[]): void;
|
|
12
|
+
/**
|
|
13
|
+
* Testing utility to validate the non-existence of some provided file paths using a specific file system
|
|
14
|
+
*
|
|
15
|
+
* @param fs the file system to use to validate the non-existence of some files
|
|
16
|
+
* @param filePaths the paths to validate
|
|
17
|
+
* @throws when one or more of the provided file paths is found
|
|
18
|
+
*/
|
|
19
|
+
export declare function expectFilesDoNotExist(fs: d.InMemoryFileSystem, filePaths: string[]): void;
|
|
5
20
|
export declare function getAppScriptUrl(config: d.Config, browserUrl: string): string;
|
|
6
21
|
export declare function getAppStyleUrl(config: d.Config, browserUrl: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Utility for silencing `console` functions in tests.
|
|
24
|
+
*
|
|
25
|
+
* When this function is first called it grabs a reference to the `log`,
|
|
26
|
+
* `error`, and `warn` functions on `console` and then returns a per-test setup
|
|
27
|
+
* function which sets up a fresh set of mocks (via `jest.fn()`) and then
|
|
28
|
+
* assigns them to each of these functions. This setup function will return a
|
|
29
|
+
* reference to each of the three mock functions so tests can make assertions
|
|
30
|
+
* about their calls and so on.
|
|
31
|
+
*
|
|
32
|
+
* Because references to the original `.log`, `.error`, and `.warn` functions
|
|
33
|
+
* exist in closure within the function, it can use an `afterAll` call to clean
|
|
34
|
+
* up after itself and ensure that the original implementations are restored
|
|
35
|
+
* after the test suite finishes.
|
|
36
|
+
*
|
|
37
|
+
* An example of using this to silence log statements in a single test could look
|
|
38
|
+
* like this:
|
|
39
|
+
*
|
|
40
|
+
* ```ts
|
|
41
|
+
* describe("my-test-suite", () => {
|
|
42
|
+
* const setupConsoleMocks = setupConsoleMocker()
|
|
43
|
+
*
|
|
44
|
+
* it("should log a message", () => {
|
|
45
|
+
* const { logMock } = setupConsoleMocks();
|
|
46
|
+
* myFunctionWhichLogs(foo, bar);
|
|
47
|
+
* expect(logMock).toBeCalledWith('my log message');
|
|
48
|
+
* })
|
|
49
|
+
* })
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @returns a per-test mock setup function
|
|
53
|
+
*/
|
|
54
|
+
export declare function setupConsoleMocker(): ConsoleMocker;
|
|
55
|
+
interface ConsoleMocker {
|
|
56
|
+
(): {
|
|
57
|
+
logMock: jest.Mock<typeof console.log>;
|
|
58
|
+
warnMock: jest.Mock<typeof console.warn>;
|
|
59
|
+
errorMock: jest.Mock<typeof console.error>;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* the callback that `withSilentWarn` expects to receive. Basically receives a mock
|
|
64
|
+
* as its argument and returns a `Promise`, the value of which is returns by `withSilentWarn`
|
|
65
|
+
* as well.
|
|
66
|
+
*/
|
|
67
|
+
declare type SilentWarnFunc<T> = (mock: jest.Mock<typeof console.warn>) => Promise<T>;
|
|
68
|
+
/**
|
|
69
|
+
* Wrap a single callback with a silent `console.warn`. The callback passed in
|
|
70
|
+
* receives the mocking function as an argument, so you can easily make assertions
|
|
71
|
+
* that it is called if necessary.
|
|
72
|
+
*
|
|
73
|
+
* @param cb a callback which `withSilentWarn` will call after replacing `console.warn`
|
|
74
|
+
* with a mock.
|
|
75
|
+
* @returns a Promise wrapping the return value of the callback
|
|
76
|
+
*/
|
|
77
|
+
export declare function withSilentWarn<T>(cb: SilentWarnFunc<T>): Promise<T>;
|
|
78
|
+
export {};
|
package/testing/testing.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const createTesting: (config:
|
|
1
|
+
import type { ValidatedConfig, Testing } from '@rindo/core/internal';
|
|
2
|
+
export declare const createTesting: (config: ValidatedConfig) => Promise<Testing>;
|