@matter/tools 0.11.0-alpha.0-20241005-e3e4e4a7a
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/LICENSE +201 -0
- package/README.md +100 -0
- package/bin/build.js +10 -0
- package/bin/prepare-chip.js +5 -0
- package/bin/run.js +7 -0
- package/bin/test.js +7 -0
- package/bin/version.js +7 -0
- package/chip/Dockerfile +23 -0
- package/dist/cjs/building/builder.d.ts +35 -0
- package/dist/cjs/building/builder.d.ts.map +1 -0
- package/dist/cjs/building/builder.js +210 -0
- package/dist/cjs/building/builder.js.map +6 -0
- package/dist/cjs/building/cli.d.ts +7 -0
- package/dist/cjs/building/cli.d.ts.map +1 -0
- package/dist/cjs/building/cli.js +100 -0
- package/dist/cjs/building/cli.js.map +6 -0
- package/dist/cjs/building/error.d.ts +16 -0
- package/dist/cjs/building/error.d.ts.map +1 -0
- package/dist/cjs/building/error.js +50 -0
- package/dist/cjs/building/error.js.map +6 -0
- package/dist/cjs/building/graph.d.ts +37 -0
- package/dist/cjs/building/graph.d.ts.map +1 -0
- package/dist/cjs/building/graph.js +222 -0
- package/dist/cjs/building/graph.js.map +6 -0
- package/dist/cjs/building/project.d.ts +56 -0
- package/dist/cjs/building/project.d.ts.map +1 -0
- package/dist/cjs/building/project.js +239 -0
- package/dist/cjs/building/project.js.map +6 -0
- package/dist/cjs/building/tsconfig.d.ts +16 -0
- package/dist/cjs/building/tsconfig.d.ts.map +1 -0
- package/dist/cjs/building/tsconfig.js +70 -0
- package/dist/cjs/building/tsconfig.js.map +6 -0
- package/dist/cjs/building/typescript/context.d.ts +16 -0
- package/dist/cjs/building/typescript/context.d.ts.map +1 -0
- package/dist/cjs/building/typescript/context.js +82 -0
- package/dist/cjs/building/typescript/context.js.map +6 -0
- package/dist/cjs/building/typescript/incremental-compiler.d.ts +10 -0
- package/dist/cjs/building/typescript/incremental-compiler.d.ts.map +1 -0
- package/dist/cjs/building/typescript/incremental-compiler.js +119 -0
- package/dist/cjs/building/typescript/incremental-compiler.js.map +6 -0
- package/dist/cjs/building/typescript/language-service.d.ts +13 -0
- package/dist/cjs/building/typescript/language-service.d.ts.map +1 -0
- package/dist/cjs/building/typescript/language-service.js +109 -0
- package/dist/cjs/building/typescript/language-service.js.map +6 -0
- package/dist/cjs/building/typescript/solution-builder.d.ts +10 -0
- package/dist/cjs/building/typescript/solution-builder.d.ts.map +1 -0
- package/dist/cjs/building/typescript/solution-builder.js +72 -0
- package/dist/cjs/building/typescript/solution-builder.js.map +6 -0
- package/dist/cjs/building/typescript.d.ts +13 -0
- package/dist/cjs/building/typescript.d.ts.map +1 -0
- package/dist/cjs/building/typescript.js +31 -0
- package/dist/cjs/building/typescript.js.map +6 -0
- package/dist/cjs/index.d.ts +15 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +32 -0
- package/dist/cjs/index.js.map +6 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/running/cli.d.ts +19 -0
- package/dist/cjs/running/cli.d.ts.map +1 -0
- package/dist/cjs/running/cli.js +82 -0
- package/dist/cjs/running/cli.js.map +6 -0
- package/dist/cjs/running/execute.d.ts +8 -0
- package/dist/cjs/running/execute.d.ts.map +1 -0
- package/dist/cjs/running/execute.js +82 -0
- package/dist/cjs/running/execute.js.map +6 -0
- package/dist/cjs/testing/chip/pics-file.d.ts +20 -0
- package/dist/cjs/testing/chip/pics-file.d.ts.map +1 -0
- package/dist/cjs/testing/chip/pics-file.js +79 -0
- package/dist/cjs/testing/chip/pics-file.js.map +6 -0
- package/dist/cjs/testing/chip.d.ts +60 -0
- package/dist/cjs/testing/chip.d.ts.map +1 -0
- package/dist/cjs/testing/chip.js +306 -0
- package/dist/cjs/testing/chip.js.map +6 -0
- package/dist/cjs/testing/cli.d.ts +9 -0
- package/dist/cjs/testing/cli.d.ts.map +1 -0
- package/dist/cjs/testing/cli.js +117 -0
- package/dist/cjs/testing/cli.js.map +6 -0
- package/dist/cjs/testing/failure-detail.d.ts +19 -0
- package/dist/cjs/testing/failure-detail.d.ts.map +1 -0
- package/dist/cjs/testing/failure-detail.js +143 -0
- package/dist/cjs/testing/failure-detail.js.map +6 -0
- package/dist/cjs/testing/files.d.ts +8 -0
- package/dist/cjs/testing/files.d.ts.map +1 -0
- package/dist/cjs/testing/files.js +52 -0
- package/dist/cjs/testing/files.js.map +6 -0
- package/dist/cjs/testing/global-declarations.d.ts +38 -0
- package/dist/cjs/testing/global-declarations.d.ts.map +1 -0
- package/dist/cjs/testing/global-declarations.js +8 -0
- package/dist/cjs/testing/global-declarations.js.map +6 -0
- package/dist/cjs/testing/global-definitions.d.ts +7 -0
- package/dist/cjs/testing/global-definitions.d.ts.map +1 -0
- package/dist/cjs/testing/global-definitions.js +50 -0
- package/dist/cjs/testing/global-definitions.js.map +6 -0
- package/dist/cjs/testing/mocha.d.ts +36 -0
- package/dist/cjs/testing/mocha.d.ts.map +1 -0
- package/dist/cjs/testing/mocha.js +155 -0
- package/dist/cjs/testing/mocha.js.map +6 -0
- package/dist/cjs/testing/mocharc.cjs +68 -0
- package/dist/cjs/testing/mocharc.d.cts +7 -0
- package/dist/cjs/testing/mocks/crypto.d.ts +7 -0
- package/dist/cjs/testing/mocks/crypto.d.ts.map +1 -0
- package/dist/cjs/testing/mocks/crypto.js +79 -0
- package/dist/cjs/testing/mocks/crypto.js.map +6 -0
- package/dist/cjs/testing/mocks/environment.d.ts +7 -0
- package/dist/cjs/testing/mocks/environment.d.ts.map +1 -0
- package/dist/cjs/testing/mocks/environment.js +7 -0
- package/dist/cjs/testing/mocks/environment.js.map +6 -0
- package/dist/cjs/testing/mocks/index.d.ts +10 -0
- package/dist/cjs/testing/mocks/index.d.ts.map +1 -0
- package/dist/cjs/testing/mocks/index.js +27 -0
- package/dist/cjs/testing/mocks/index.js.map +6 -0
- package/dist/cjs/testing/mocks/logging.d.ts +28 -0
- package/dist/cjs/testing/mocks/logging.d.ts.map +1 -0
- package/dist/cjs/testing/mocks/logging.js +93 -0
- package/dist/cjs/testing/mocks/logging.js.map +6 -0
- package/dist/cjs/testing/mocks/time.d.ts +88 -0
- package/dist/cjs/testing/mocks/time.d.ts.map +1 -0
- package/dist/cjs/testing/mocks/time.js +250 -0
- package/dist/cjs/testing/mocks/time.js.map +6 -0
- package/dist/cjs/testing/node.d.ts +16 -0
- package/dist/cjs/testing/node.d.ts.map +1 -0
- package/dist/cjs/testing/node.js +108 -0
- package/dist/cjs/testing/node.js.map +6 -0
- package/dist/cjs/testing/options.d.ts +19 -0
- package/dist/cjs/testing/options.d.ts.map +1 -0
- package/dist/cjs/testing/options.js +62 -0
- package/dist/cjs/testing/options.js.map +6 -0
- package/dist/cjs/testing/reporter.d.ts +50 -0
- package/dist/cjs/testing/reporter.d.ts.map +1 -0
- package/dist/cjs/testing/reporter.js +137 -0
- package/dist/cjs/testing/reporter.js.map +6 -0
- package/dist/cjs/testing/runner.d.ts +22 -0
- package/dist/cjs/testing/runner.d.ts.map +1 -0
- package/dist/cjs/testing/runner.js +116 -0
- package/dist/cjs/testing/runner.js.map +6 -0
- package/dist/cjs/testing/web.d.ts +8 -0
- package/dist/cjs/testing/web.d.ts.map +1 -0
- package/dist/cjs/testing/web.js +165 -0
- package/dist/cjs/testing/web.js.map +6 -0
- package/dist/cjs/util/bootstrap.mjs +105 -0
- package/dist/cjs/util/docker.d.ts +27 -0
- package/dist/cjs/util/docker.d.ts.map +1 -0
- package/dist/cjs/util/docker.js +163 -0
- package/dist/cjs/util/docker.js.map +6 -0
- package/dist/cjs/util/errors.d.ts +8 -0
- package/dist/cjs/util/errors.d.ts.map +1 -0
- package/dist/cjs/util/errors.js +55 -0
- package/dist/cjs/util/errors.js.map +6 -0
- package/dist/cjs/util/index.d.ts +8 -0
- package/dist/cjs/util/index.d.ts.map +1 -0
- package/dist/cjs/util/index.js +25 -0
- package/dist/cjs/util/index.js.map +6 -0
- package/dist/cjs/util/node-shims.d.ts +7 -0
- package/dist/cjs/util/node-shims.d.ts.map +1 -0
- package/dist/cjs/util/node-shims.js +12 -0
- package/dist/cjs/util/node-shims.js.map +6 -0
- package/dist/cjs/util/package.d.ts +61 -0
- package/dist/cjs/util/package.d.ts.map +1 -0
- package/dist/cjs/util/package.js +324 -0
- package/dist/cjs/util/package.js.map +6 -0
- package/dist/cjs/util/progress.d.ts +31 -0
- package/dist/cjs/util/progress.d.ts.map +1 -0
- package/dist/cjs/util/progress.js +232 -0
- package/dist/cjs/util/progress.js.map +6 -0
- package/dist/cjs/util/tools-path.cjs +13 -0
- package/dist/cjs/util/tools-path.d.cts +7 -0
- package/dist/cjs/util/trace-unhandled.d.ts +9 -0
- package/dist/cjs/util/trace-unhandled.d.ts.map +1 -0
- package/dist/cjs/util/trace-unhandled.js +48 -0
- package/dist/cjs/util/trace-unhandled.js.map +6 -0
- package/dist/cjs/util/wtf.d.ts +10 -0
- package/dist/cjs/util/wtf.d.ts.map +1 -0
- package/dist/cjs/util/wtf.js +53 -0
- package/dist/cjs/util/wtf.js.map +6 -0
- package/dist/cjs/versioning/cli.d.ts +7 -0
- package/dist/cjs/versioning/cli.d.ts.map +1 -0
- package/dist/cjs/versioning/cli.js +62 -0
- package/dist/cjs/versioning/cli.js.map +6 -0
- package/dist/cjs/versioning/versioner.d.ts +18 -0
- package/dist/cjs/versioning/versioner.d.ts.map +1 -0
- package/dist/cjs/versioning/versioner.js +145 -0
- package/dist/cjs/versioning/versioner.js.map +6 -0
- package/dist/esm/building/builder.d.ts +35 -0
- package/dist/esm/building/builder.d.ts.map +1 -0
- package/dist/esm/building/builder.js +180 -0
- package/dist/esm/building/builder.js.map +6 -0
- package/dist/esm/building/cli.d.ts +7 -0
- package/dist/esm/building/cli.d.ts.map +1 -0
- package/dist/esm/building/cli.js +70 -0
- package/dist/esm/building/cli.js.map +6 -0
- package/dist/esm/building/error.d.ts +16 -0
- package/dist/esm/building/error.d.ts.map +1 -0
- package/dist/esm/building/error.js +30 -0
- package/dist/esm/building/error.js.map +6 -0
- package/dist/esm/building/graph.d.ts +37 -0
- package/dist/esm/building/graph.d.ts.map +1 -0
- package/dist/esm/building/graph.js +192 -0
- package/dist/esm/building/graph.js.map +6 -0
- package/dist/esm/building/project.d.ts +56 -0
- package/dist/esm/building/project.d.ts.map +1 -0
- package/dist/esm/building/project.js +219 -0
- package/dist/esm/building/project.js.map +6 -0
- package/dist/esm/building/tsconfig.d.ts +16 -0
- package/dist/esm/building/tsconfig.d.ts.map +1 -0
- package/dist/esm/building/tsconfig.js +50 -0
- package/dist/esm/building/tsconfig.js.map +6 -0
- package/dist/esm/building/typescript/context.d.ts +16 -0
- package/dist/esm/building/typescript/context.d.ts.map +1 -0
- package/dist/esm/building/typescript/context.js +68 -0
- package/dist/esm/building/typescript/context.js.map +6 -0
- package/dist/esm/building/typescript/incremental-compiler.d.ts +10 -0
- package/dist/esm/building/typescript/incremental-compiler.d.ts.map +1 -0
- package/dist/esm/building/typescript/incremental-compiler.js +99 -0
- package/dist/esm/building/typescript/incremental-compiler.js.map +6 -0
- package/dist/esm/building/typescript/language-service.d.ts +13 -0
- package/dist/esm/building/typescript/language-service.d.ts.map +1 -0
- package/dist/esm/building/typescript/language-service.js +99 -0
- package/dist/esm/building/typescript/language-service.js.map +6 -0
- package/dist/esm/building/typescript/solution-builder.d.ts +10 -0
- package/dist/esm/building/typescript/solution-builder.d.ts.map +1 -0
- package/dist/esm/building/typescript/solution-builder.js +52 -0
- package/dist/esm/building/typescript/solution-builder.js.map +6 -0
- package/dist/esm/building/typescript.d.ts +13 -0
- package/dist/esm/building/typescript.d.ts.map +1 -0
- package/dist/esm/building/typescript.js +11 -0
- package/dist/esm/building/typescript.js.map +6 -0
- package/dist/esm/index.d.ts +15 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +15 -0
- package/dist/esm/index.js.map +6 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/running/cli.d.ts +19 -0
- package/dist/esm/running/cli.d.ts.map +1 -0
- package/dist/esm/running/cli.js +62 -0
- package/dist/esm/running/cli.js.map +6 -0
- package/dist/esm/running/execute.d.ts +8 -0
- package/dist/esm/running/execute.d.ts.map +1 -0
- package/dist/esm/running/execute.js +52 -0
- package/dist/esm/running/execute.js.map +6 -0
- package/dist/esm/testing/chip/pics-file.d.ts +20 -0
- package/dist/esm/testing/chip/pics-file.d.ts.map +1 -0
- package/dist/esm/testing/chip/pics-file.js +59 -0
- package/dist/esm/testing/chip/pics-file.js.map +6 -0
- package/dist/esm/testing/chip.d.ts +60 -0
- package/dist/esm/testing/chip.d.ts.map +1 -0
- package/dist/esm/testing/chip.js +286 -0
- package/dist/esm/testing/chip.js.map +6 -0
- package/dist/esm/testing/cli.d.ts +9 -0
- package/dist/esm/testing/cli.d.ts.map +1 -0
- package/dist/esm/testing/cli.js +87 -0
- package/dist/esm/testing/cli.js.map +6 -0
- package/dist/esm/testing/failure-detail.d.ts +19 -0
- package/dist/esm/testing/failure-detail.d.ts.map +1 -0
- package/dist/esm/testing/failure-detail.js +113 -0
- package/dist/esm/testing/failure-detail.js.map +6 -0
- package/dist/esm/testing/files.d.ts +8 -0
- package/dist/esm/testing/files.d.ts.map +1 -0
- package/dist/esm/testing/files.js +32 -0
- package/dist/esm/testing/files.js.map +6 -0
- package/dist/esm/testing/global-declarations.d.ts +38 -0
- package/dist/esm/testing/global-declarations.d.ts.map +1 -0
- package/dist/esm/testing/global-declarations.js +7 -0
- package/dist/esm/testing/global-declarations.js.map +6 -0
- package/dist/esm/testing/global-definitions.d.ts +7 -0
- package/dist/esm/testing/global-definitions.d.ts.map +1 -0
- package/dist/esm/testing/global-definitions.js +27 -0
- package/dist/esm/testing/global-definitions.js.map +6 -0
- package/dist/esm/testing/mocha.d.ts +36 -0
- package/dist/esm/testing/mocha.d.ts.map +1 -0
- package/dist/esm/testing/mocha.js +135 -0
- package/dist/esm/testing/mocha.js.map +6 -0
- package/dist/esm/testing/mocharc.cjs +68 -0
- package/dist/esm/testing/mocharc.d.cts +7 -0
- package/dist/esm/testing/mocks/crypto.d.ts +7 -0
- package/dist/esm/testing/mocks/crypto.d.ts.map +1 -0
- package/dist/esm/testing/mocks/crypto.js +59 -0
- package/dist/esm/testing/mocks/crypto.js.map +6 -0
- package/dist/esm/testing/mocks/environment.d.ts +7 -0
- package/dist/esm/testing/mocks/environment.d.ts.map +1 -0
- package/dist/esm/testing/mocks/environment.js +6 -0
- package/dist/esm/testing/mocks/environment.js.map +6 -0
- package/dist/esm/testing/mocks/index.d.ts +10 -0
- package/dist/esm/testing/mocks/index.d.ts.map +1 -0
- package/dist/esm/testing/mocks/index.js +10 -0
- package/dist/esm/testing/mocks/index.js.map +6 -0
- package/dist/esm/testing/mocks/logging.d.ts +28 -0
- package/dist/esm/testing/mocks/logging.d.ts.map +1 -0
- package/dist/esm/testing/mocks/logging.js +63 -0
- package/dist/esm/testing/mocks/logging.js.map +6 -0
- package/dist/esm/testing/mocks/time.d.ts +88 -0
- package/dist/esm/testing/mocks/time.d.ts.map +1 -0
- package/dist/esm/testing/mocks/time.js +230 -0
- package/dist/esm/testing/mocks/time.js.map +6 -0
- package/dist/esm/testing/node.d.ts +16 -0
- package/dist/esm/testing/node.d.ts.map +1 -0
- package/dist/esm/testing/node.js +78 -0
- package/dist/esm/testing/node.js.map +6 -0
- package/dist/esm/testing/options.d.ts +19 -0
- package/dist/esm/testing/options.d.ts.map +1 -0
- package/dist/esm/testing/options.js +42 -0
- package/dist/esm/testing/options.js.map +6 -0
- package/dist/esm/testing/reporter.d.ts +50 -0
- package/dist/esm/testing/reporter.d.ts.map +1 -0
- package/dist/esm/testing/reporter.js +107 -0
- package/dist/esm/testing/reporter.js.map +6 -0
- package/dist/esm/testing/runner.d.ts +22 -0
- package/dist/esm/testing/runner.d.ts.map +1 -0
- package/dist/esm/testing/runner.js +86 -0
- package/dist/esm/testing/runner.js.map +6 -0
- package/dist/esm/testing/web.d.ts +8 -0
- package/dist/esm/testing/web.d.ts.map +1 -0
- package/dist/esm/testing/web.js +135 -0
- package/dist/esm/testing/web.js.map +6 -0
- package/dist/esm/util/bootstrap.mjs +105 -0
- package/dist/esm/util/docker.d.ts +27 -0
- package/dist/esm/util/docker.d.ts.map +1 -0
- package/dist/esm/util/docker.js +133 -0
- package/dist/esm/util/docker.js.map +6 -0
- package/dist/esm/util/errors.d.ts +8 -0
- package/dist/esm/util/errors.d.ts.map +1 -0
- package/dist/esm/util/errors.js +35 -0
- package/dist/esm/util/errors.js.map +6 -0
- package/dist/esm/util/index.d.ts +8 -0
- package/dist/esm/util/index.d.ts.map +1 -0
- package/dist/esm/util/index.js +8 -0
- package/dist/esm/util/index.js.map +6 -0
- package/dist/esm/util/node-shims.d.ts +7 -0
- package/dist/esm/util/node-shims.d.ts.map +1 -0
- package/dist/esm/util/node-shims.js +11 -0
- package/dist/esm/util/node-shims.js.map +6 -0
- package/dist/esm/util/package.d.ts +61 -0
- package/dist/esm/util/package.d.ts.map +1 -0
- package/dist/esm/util/package.js +304 -0
- package/dist/esm/util/package.js.map +6 -0
- package/dist/esm/util/progress.d.ts +31 -0
- package/dist/esm/util/progress.d.ts.map +1 -0
- package/dist/esm/util/progress.js +202 -0
- package/dist/esm/util/progress.js.map +6 -0
- package/dist/esm/util/tools-path.cjs +13 -0
- package/dist/esm/util/tools-path.d.cts +7 -0
- package/dist/esm/util/trace-unhandled.d.ts +9 -0
- package/dist/esm/util/trace-unhandled.d.ts.map +1 -0
- package/dist/esm/util/trace-unhandled.js +18 -0
- package/dist/esm/util/trace-unhandled.js.map +6 -0
- package/dist/esm/util/wtf.d.ts +10 -0
- package/dist/esm/util/wtf.d.ts.map +1 -0
- package/dist/esm/util/wtf.js +23 -0
- package/dist/esm/util/wtf.js.map +6 -0
- package/dist/esm/versioning/cli.d.ts +7 -0
- package/dist/esm/versioning/cli.d.ts.map +1 -0
- package/dist/esm/versioning/cli.js +32 -0
- package/dist/esm/versioning/cli.js.map +6 -0
- package/dist/esm/versioning/versioner.d.ts +18 -0
- package/dist/esm/versioning/versioner.d.ts.map +1 -0
- package/dist/esm/versioning/versioner.js +115 -0
- package/dist/esm/versioning/versioner.js.map +6 -0
- package/package.json +82 -0
- package/src/building/builder.ts +216 -0
- package/src/building/cli.ts +89 -0
- package/src/building/error.ts +29 -0
- package/src/building/graph.ts +251 -0
- package/src/building/project.ts +313 -0
- package/src/building/tsconfig.ts +69 -0
- package/src/building/typescript/context.ts +85 -0
- package/src/building/typescript/incremental-compiler.ts +126 -0
- package/src/building/typescript/language-service.ts +132 -0
- package/src/building/typescript/solution-builder.ts +67 -0
- package/src/building/typescript.ts +15 -0
- package/src/index.ts +15 -0
- package/src/running/cli.ts +95 -0
- package/src/running/execute.ts +63 -0
- package/src/testing/chip/pics-file.ts +71 -0
- package/src/testing/chip/pics.properties +53 -0
- package/src/testing/chip.ts +420 -0
- package/src/testing/cli.ts +122 -0
- package/src/testing/failure-detail.ts +126 -0
- package/src/testing/files.ts +35 -0
- package/src/testing/global-declarations.ts +50 -0
- package/src/testing/global-definitions.ts +35 -0
- package/src/testing/index.html +16 -0
- package/src/testing/mocha.ts +162 -0
- package/src/testing/mocharc.cjs +68 -0
- package/src/testing/mocharc.d.cts +7 -0
- package/src/testing/mocks/crypto.ts +70 -0
- package/src/testing/mocks/environment.ts +7 -0
- package/src/testing/mocks/index.ts +10 -0
- package/src/testing/mocks/logging.ts +99 -0
- package/src/testing/mocks/time.ts +294 -0
- package/src/testing/node.ts +114 -0
- package/src/testing/options.ts +58 -0
- package/src/testing/reporter.ts +144 -0
- package/src/testing/runner.ts +98 -0
- package/src/testing/web.ts +174 -0
- package/src/tsconfig.json +14 -0
- package/src/util/bootstrap.mjs +105 -0
- package/src/util/docker.ts +176 -0
- package/src/util/errors.ts +33 -0
- package/src/util/index.ts +8 -0
- package/src/util/node-shims.ts +13 -0
- package/src/util/package.ts +369 -0
- package/src/util/progress.ts +252 -0
- package/src/util/tools-path.cjs +13 -0
- package/src/util/tools-path.d.cts +7 -0
- package/src/util/trace-unhandled.ts +17 -0
- package/src/util/wtf.ts +25 -0
- package/src/versioning/cli.ts +43 -0
- package/src/versioning/versioner.ts +139 -0
- package/test/testing/mocks/MockTimeTest.ts +113 -0
- package/test/tsconfig.json +15 -0
- package/tsc/tsconfig.app.json +7 -0
- package/tsc/tsconfig.base.json +41 -0
- package/tsc/tsconfig.lib.json +12 -0
- package/tsc/tsconfig.test.json +7 -0
- package/tsconfig.json +5 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2024 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import colors from "ansi-colors";
|
|
8
|
+
|
|
9
|
+
export interface FailureDetail {
|
|
10
|
+
message: string;
|
|
11
|
+
stack?: string;
|
|
12
|
+
diff?: string;
|
|
13
|
+
logs?: string;
|
|
14
|
+
cause?: FailureDetail;
|
|
15
|
+
errors?: FailureDetail[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function FailureDetail(error: any, logs?: string[]) {
|
|
19
|
+
let diff: string | undefined;
|
|
20
|
+
|
|
21
|
+
const { message, stack, cause, errors } = parseError(error);
|
|
22
|
+
|
|
23
|
+
if (error.expected && error.actual) {
|
|
24
|
+
if (FailureDetail.diff === undefined) {
|
|
25
|
+
diff = "(no diff implementation installed)";
|
|
26
|
+
} else {
|
|
27
|
+
diff = FailureDetail.diff(error.actual.toString(), error.expected.toString());
|
|
28
|
+
diff = diff.trim().replace(/^ {6}/gms, "");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const result = { message } as FailureDetail;
|
|
33
|
+
if (diff) {
|
|
34
|
+
result.diff = diff;
|
|
35
|
+
}
|
|
36
|
+
if (stack) {
|
|
37
|
+
result.stack = stack;
|
|
38
|
+
}
|
|
39
|
+
if (logs?.length) {
|
|
40
|
+
result.logs = logs.join("\n");
|
|
41
|
+
}
|
|
42
|
+
if (cause) {
|
|
43
|
+
result.cause = cause;
|
|
44
|
+
}
|
|
45
|
+
if (errors) {
|
|
46
|
+
result.errors = errors;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export namespace FailureDetail {
|
|
53
|
+
export function dump(failure: FailureDetail, prefix: string = "") {
|
|
54
|
+
process.stdout.write(colors.redBright(`${prefix}${failure.message}\n\n`));
|
|
55
|
+
|
|
56
|
+
if (failure.diff) {
|
|
57
|
+
process.stdout.write(`${prefix} ${failure.diff.replace(/\n/gm, "\n ")}\n\n`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (failure.stack) {
|
|
61
|
+
process.stdout.write(`${prefix}${colors.dim(failure.stack.replace(/\n/gm, `\n${prefix}`))}\n\n`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (failure.cause) {
|
|
65
|
+
process.stdout.write(`${prefix}Caused by:\n\n`);
|
|
66
|
+
dump(failure.cause, prefix);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (failure.errors?.length) {
|
|
70
|
+
let num = 0;
|
|
71
|
+
for (const cause of failure.errors) {
|
|
72
|
+
process.stdout.write(`${prefix}Cause #${++num}:\n\n`);
|
|
73
|
+
dump(cause, `${prefix} `);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (failure.logs) {
|
|
78
|
+
process.stdout.write(` ${failure.logs.replace(/\n/gm, "\n ")}\n\n`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export let diff: undefined | ((actual: string, expected: string) => string);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function parseError(error: Error) {
|
|
86
|
+
let message, stack, cause: FailureDetail | undefined, errors: FailureDetail[] | undefined;
|
|
87
|
+
|
|
88
|
+
if (error === undefined || error === null) {
|
|
89
|
+
message = `(error is ${error})`;
|
|
90
|
+
} else {
|
|
91
|
+
message = error.message;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (error.stack) {
|
|
95
|
+
let lines = error.stack.trim().split("\n");
|
|
96
|
+
if (!message) {
|
|
97
|
+
message = lines[0];
|
|
98
|
+
}
|
|
99
|
+
lines = lines.filter(line => line.match(/:\d+:\d+\)?/));
|
|
100
|
+
if (lines.length) {
|
|
101
|
+
stack = lines.map(line => line.trim()).join("\n");
|
|
102
|
+
}
|
|
103
|
+
} else if (error.message) {
|
|
104
|
+
message = error.message;
|
|
105
|
+
} else {
|
|
106
|
+
message = error.toString();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
message = message.trim().replace(/Error: /, "");
|
|
110
|
+
|
|
111
|
+
if (message.endsWith(":")) {
|
|
112
|
+
message = message.slice(0, message.length - 1);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const errorCause = error.cause;
|
|
116
|
+
if (errorCause) {
|
|
117
|
+
cause = FailureDetail(errorCause);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const errorErrors = (error as AggregateError).errors;
|
|
121
|
+
if (Array.isArray(errorErrors)) {
|
|
122
|
+
errors = errorErrors.map(e => FailureDetail(e));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return { message, stack, cause, errors };
|
|
126
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2024 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { existsSync, statSync } from "fs";
|
|
8
|
+
import { Package } from "../util/package.js";
|
|
9
|
+
|
|
10
|
+
export function listSupportFiles(format = "cjs") {
|
|
11
|
+
const files = Array<string>();
|
|
12
|
+
|
|
13
|
+
// Always load tooling code in ESM format as tooling globals load as ESM
|
|
14
|
+
files.push(Package.tools.resolve("dist/esm/testing/global-definitions.js"));
|
|
15
|
+
files.push(Package.tools.resolve("dist/esm/testing/mocks/index.js"));
|
|
16
|
+
|
|
17
|
+
// Package code should load in the format being tested
|
|
18
|
+
const config = new Package().resolve(`build/${format}/test/test.config.js`);
|
|
19
|
+
if (existsSync(config)) {
|
|
20
|
+
files.push(config);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return files;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function maybeStatSync(path: string) {
|
|
27
|
+
try {
|
|
28
|
+
return statSync(path);
|
|
29
|
+
} catch (e) {
|
|
30
|
+
if (typeof e === "object" && e !== null && "code" in e && (e.code === "ENOENT" || e.code === "ENOTDIR")) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
throw e;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2024 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type Chai from "chai";
|
|
8
|
+
import "chai-as-promised";
|
|
9
|
+
import type { MockLogger } from "./mocks/logging.js";
|
|
10
|
+
import type { MockTime } from "./mocks/time.js";
|
|
11
|
+
|
|
12
|
+
declare global {
|
|
13
|
+
// Expose Chai globally
|
|
14
|
+
const expect: typeof Chai.expect;
|
|
15
|
+
|
|
16
|
+
// Expose API for controlling time
|
|
17
|
+
let MockTime: MockTime;
|
|
18
|
+
|
|
19
|
+
// Expose API for controlling logging
|
|
20
|
+
let MockLogger: MockLogger;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* If present, the following hooks are engaged by matter.js packages to
|
|
24
|
+
* enable mocking. We use globals rather than imports so we can hook the
|
|
25
|
+
* modules regardless of whether they're loaded as CommonJS or ESM.
|
|
26
|
+
*/
|
|
27
|
+
let MatterHooks:
|
|
28
|
+
| undefined
|
|
29
|
+
| {
|
|
30
|
+
/**
|
|
31
|
+
* Configure time.
|
|
32
|
+
*/
|
|
33
|
+
timeSetup?: (Time: any) => void;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Configure logging.
|
|
37
|
+
*/
|
|
38
|
+
loggerSetup?: (Logger: any) => void;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Configure crypto.
|
|
42
|
+
*/
|
|
43
|
+
cryptoSetup?: (Crypto: any) => void;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Receive intercepted log messages. The logging mocks
|
|
47
|
+
*/
|
|
48
|
+
loggerSink?: (level: number, message: string) => void;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2024 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// Note - we don't import mocha here because in the browser we load their standard browser bundle which is different
|
|
8
|
+
// from the Node version
|
|
9
|
+
|
|
10
|
+
import Chai from "chai";
|
|
11
|
+
import ChaiAsPromised from "chai-as-promised";
|
|
12
|
+
import { browserSetup, generalSetup } from "./mocha.js";
|
|
13
|
+
import { cryptoSetup } from "./mocks/crypto.js";
|
|
14
|
+
import { TheMockLogger, loggerSetup } from "./mocks/logging.js";
|
|
15
|
+
import { timeSetup } from "./mocks/time.js";
|
|
16
|
+
|
|
17
|
+
Chai.config.truncateThreshold = 200;
|
|
18
|
+
Chai.use(ChaiAsPromised);
|
|
19
|
+
|
|
20
|
+
Object.assign(globalThis, {
|
|
21
|
+
expect: Chai.expect,
|
|
22
|
+
|
|
23
|
+
MatterHooks: {
|
|
24
|
+
loggerSetup,
|
|
25
|
+
timeSetup,
|
|
26
|
+
cryptoSetup,
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
MockLogger: TheMockLogger,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (typeof window === "object" && globalThis === window) {
|
|
33
|
+
generalSetup(mocha);
|
|
34
|
+
browserSetup(mocha);
|
|
35
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Matter.js Web Testing</title>
|
|
5
|
+
<link rel="stylesheet" href="mocha/mocha.css">
|
|
6
|
+
</head>
|
|
7
|
+
<body>
|
|
8
|
+
<div id="mocha"></div>
|
|
9
|
+
<script src="mocha/mocha.js"></script>
|
|
10
|
+
<script src="tests.js"></script>
|
|
11
|
+
<script>
|
|
12
|
+
mocha.setup("bdd");
|
|
13
|
+
mocha.run();
|
|
14
|
+
</script>
|
|
15
|
+
</body>
|
|
16
|
+
</html>
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2024 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// Can't import Mocha in the browser so just import type here
|
|
8
|
+
import type MochaType from "mocha";
|
|
9
|
+
import { wtf } from "../util/wtf.js";
|
|
10
|
+
import { FailureDetail } from "./failure-detail.js";
|
|
11
|
+
import { LoggerHooks } from "./mocks/logging.js";
|
|
12
|
+
import { TestOptions } from "./options.js";
|
|
13
|
+
import { ConsoleProxyReporter, Reporter } from "./reporter.js";
|
|
14
|
+
|
|
15
|
+
export function generalSetup(mocha: MochaType) {
|
|
16
|
+
const Base = (mocha.constructor as typeof MochaType).reporters.Base;
|
|
17
|
+
|
|
18
|
+
// White text, 16-bit and 256-bit green background
|
|
19
|
+
Base.colors["diff added inline"] = "97;42;48;5;22" as any;
|
|
20
|
+
|
|
21
|
+
// White text, 16-bit and 256-bit red background
|
|
22
|
+
Base.colors["diff removed inline"] = "97;41;48;5;52" as any;
|
|
23
|
+
|
|
24
|
+
// Some of our test suites have setup/teardown logic that logs profusely. Hide these logs unless something goes
|
|
25
|
+
// wrong
|
|
26
|
+
async function onlyLogFailure(fn: () => any) {
|
|
27
|
+
if (!MatterHooks) {
|
|
28
|
+
throw new Error("Matter hooks not loaded");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const logs = Array<string>();
|
|
32
|
+
const existingSink = MatterHooks.loggerSink;
|
|
33
|
+
try {
|
|
34
|
+
MatterHooks.loggerSink = (_, message) => {
|
|
35
|
+
logs.push(message);
|
|
36
|
+
};
|
|
37
|
+
return await fn();
|
|
38
|
+
} catch (e) {
|
|
39
|
+
process.stdout.write(logs.join("\n"));
|
|
40
|
+
throw e;
|
|
41
|
+
} finally {
|
|
42
|
+
MatterHooks.loggerSink = existingSink;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function filterLogs(hook: "beforeAll" | "afterAll" | "beforeEach" | "afterEach") {
|
|
47
|
+
const actual = mocha.suite[hook] as (this: any, fn: Mocha.Func) => any;
|
|
48
|
+
mocha.suite[hook] = function (this: any, fn: Mocha.Func) {
|
|
49
|
+
return actual.call(this, async function (this: any, ...args: any) {
|
|
50
|
+
return await onlyLogFailure(() => fn.apply(this, args));
|
|
51
|
+
});
|
|
52
|
+
} as any;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
filterLogs("beforeAll");
|
|
56
|
+
filterLogs("afterAll");
|
|
57
|
+
filterLogs("beforeEach");
|
|
58
|
+
filterLogs("afterEach");
|
|
59
|
+
|
|
60
|
+
// Reset mocks before each suite. Suites could conceivably have callbacks that occur across tests. If individual
|
|
61
|
+
// tests need a reset the suite needs to handle itself.
|
|
62
|
+
const actualBeforeAll = mocha.suite.beforeAll;
|
|
63
|
+
mocha.suite.beforeAll = function (this: Mocha.Context, ...args: any) {
|
|
64
|
+
MockTime.reset();
|
|
65
|
+
return actualBeforeAll.apply(this, args);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
mocha.suite.beforeEach(() => {
|
|
69
|
+
for (const hook of LoggerHooks.beforeEach) {
|
|
70
|
+
hook(mocha);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
mocha.suite.afterEach(() => {
|
|
75
|
+
for (const hook of LoggerHooks.afterEach) {
|
|
76
|
+
hook(mocha);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
FailureDetail.diff = Base.generateDiff.bind(Base);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function adaptReporter(Mocha: typeof MochaType, title: string, reporter: Reporter) {
|
|
84
|
+
const RUNNER = Mocha.Runner.constants;
|
|
85
|
+
|
|
86
|
+
let logs = Array<string>();
|
|
87
|
+
|
|
88
|
+
class MochaReporter extends Mocha.reporters.Base {
|
|
89
|
+
constructor(runner: Mocha.Runner) {
|
|
90
|
+
super(runner);
|
|
91
|
+
|
|
92
|
+
runner.once(RUNNER.EVENT_RUN_BEGIN, () => {
|
|
93
|
+
if (!MatterHooks) {
|
|
94
|
+
throw new Error("Matter hooks not loaded");
|
|
95
|
+
}
|
|
96
|
+
MatterHooks.loggerSink = (_, message) => {
|
|
97
|
+
logs.push(message);
|
|
98
|
+
};
|
|
99
|
+
reporter.beginRun(title, this.translatedStats);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
runner.on(RUNNER.EVENT_SUITE_BEGIN, suite => {
|
|
103
|
+
reporter.beginSuite(suite.titlePath(), this.translatedStats);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
runner.on(RUNNER.EVENT_TEST_BEGIN, test => {
|
|
107
|
+
logs = (test as any).logs = [];
|
|
108
|
+
reporter.beginTest(test.title, this.translatedStats);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
runner.on(RUNNER.EVENT_TEST_FAIL, (test, error) => {
|
|
112
|
+
const logs = (test as any).logs as string[];
|
|
113
|
+
reporter.failTest(test.title, FailureDetail(error, logs));
|
|
114
|
+
wtf.dump();
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
runner.once(RUNNER.EVENT_RUN_END, () => {
|
|
118
|
+
if (!MatterHooks) {
|
|
119
|
+
throw new Error("Matter hooks not loaded");
|
|
120
|
+
}
|
|
121
|
+
MatterHooks.loggerSink = undefined;
|
|
122
|
+
reporter.endRun(this.translatedStats);
|
|
123
|
+
wtf.dump();
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
get translatedStats() {
|
|
128
|
+
return {
|
|
129
|
+
total: this.runner.total,
|
|
130
|
+
complete: this.stats.tests,
|
|
131
|
+
failures: this.stats.failures,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return MochaReporter;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function browserSetup(mocha: BrowserMocha) {
|
|
140
|
+
mocha.setup("bdd");
|
|
141
|
+
|
|
142
|
+
(globalThis as any).MatterTest = {
|
|
143
|
+
// Starts Mocha (called by clicking link)
|
|
144
|
+
start: () => {
|
|
145
|
+
const root = document.querySelector("#mocha");
|
|
146
|
+
if (root) {
|
|
147
|
+
root.innerHTML = "";
|
|
148
|
+
}
|
|
149
|
+
return mocha.run();
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
// Start Mocha, proxying reporting through console to Playwright and completing once Mocha has finished
|
|
153
|
+
auto: async function (options: TestOptions) {
|
|
154
|
+
TestOptions.apply(mocha, options);
|
|
155
|
+
mocha.reporter(adaptReporter(Mocha, "Web", new ConsoleProxyReporter()));
|
|
156
|
+
return new Promise<void>(accept => {
|
|
157
|
+
const runner = this.start();
|
|
158
|
+
runner.on("end", accept);
|
|
159
|
+
});
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2024 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// This file configures mocha for "buildless" dev execution. May be useful for running tests in IDE with Mocha support.
|
|
8
|
+
// Utilize by importing into .mocharc.cjs as a sibling of package.json in the package to test
|
|
9
|
+
|
|
10
|
+
// Required for Node < 19 (see node-shims.ts)
|
|
11
|
+
const webcrypto = require("node:crypto").webcrypto;
|
|
12
|
+
if (globalThis.crypto === undefined) {
|
|
13
|
+
Object.assign(globalThis, { crypto: webcrypto });
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function mocharc(format = "cjs") {
|
|
17
|
+
const { resolve } = require("path");
|
|
18
|
+
const cli = require("mocha/lib/cli/cli");
|
|
19
|
+
const listSupportFiles = require("./files.js").listSupportFiles;
|
|
20
|
+
|
|
21
|
+
const TOOLS = resolve(__dirname, "../../..");
|
|
22
|
+
|
|
23
|
+
const testJs = `build/${format}/test`;
|
|
24
|
+
const defaultSpec = `${testJs}/**/*Test.js`;
|
|
25
|
+
|
|
26
|
+
// Build. Ideally we'd import build code but it's asynchronous so instead
|
|
27
|
+
// build in a separate process
|
|
28
|
+
const spawnSync = require("child_process").spawnSync;
|
|
29
|
+
const result = spawnSync(`${TOOLS}/bin/build.js`, [format], { stdio: "inherit" });
|
|
30
|
+
if (result.error) {
|
|
31
|
+
console.error(result.error);
|
|
32
|
+
process.exit(-1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Hook Mocha so we can futz with args
|
|
36
|
+
const main = cli.main;
|
|
37
|
+
cli.main = function (argv, args) {
|
|
38
|
+
const spec = args._;
|
|
39
|
+
|
|
40
|
+
// Remove wildcard test selection if there's an input file
|
|
41
|
+
if (spec.length > 1 && spec[spec.length - 1] === defaultSpec) {
|
|
42
|
+
spec.length = spec.length - 1;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Map input files to the compiled test
|
|
46
|
+
for (let i = 0; i < spec.length; i++) {
|
|
47
|
+
let path = spec[i];
|
|
48
|
+
|
|
49
|
+
// Convenience - map src/ file to test equivalent
|
|
50
|
+
path = path.replace(/src\/(.*)(\.[jt]s)/, "test/$1Test$2");
|
|
51
|
+
|
|
52
|
+
// Map ts files to compiled equivalent
|
|
53
|
+
path = path.replace(/test\/(.*)\.ts/, `${testJs}/$1.js`);
|
|
54
|
+
|
|
55
|
+
spec[i] = path;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
main.call(this, argv, args);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
inlineDiffs: true,
|
|
63
|
+
file: listSupportFiles(format),
|
|
64
|
+
spec: [defaultSpec],
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
module.exports.mocharc = mocharc;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2024 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const subtle = globalThis.crypto.subtle;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* An extremely minimal Crypto mock.
|
|
11
|
+
*
|
|
12
|
+
* Only supports those subsets of crypto required to complete matter.js tests.
|
|
13
|
+
*/
|
|
14
|
+
const TheCrypto = {
|
|
15
|
+
getRandomData: (length: number) => {
|
|
16
|
+
// Make random data deterministic
|
|
17
|
+
const bytes = new Uint8Array(length);
|
|
18
|
+
|
|
19
|
+
return bytes;
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
async pbkdf2(secret: Uint8Array, salt: Uint8Array, iteration: number, keyLength: number) {
|
|
23
|
+
const key = await subtle.importKey("raw", secret, "PBKDF2", false, ["deriveBits"]);
|
|
24
|
+
const bits = await subtle.deriveBits(
|
|
25
|
+
{
|
|
26
|
+
name: "PBKDF2",
|
|
27
|
+
hash: "SHA-256",
|
|
28
|
+
salt: salt,
|
|
29
|
+
iterations: iteration,
|
|
30
|
+
},
|
|
31
|
+
key,
|
|
32
|
+
keyLength * 8,
|
|
33
|
+
);
|
|
34
|
+
return new Uint8Array(bits);
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
async hkdf(secret: Uint8Array, salt: Uint8Array, info: Uint8Array, length: number = 16) {
|
|
38
|
+
const key = await subtle.importKey("raw", secret, "HKDF", false, ["deriveBits"]);
|
|
39
|
+
return new Uint8Array(
|
|
40
|
+
await subtle.deriveBits(
|
|
41
|
+
{
|
|
42
|
+
name: "HKDF",
|
|
43
|
+
hash: "SHA-256",
|
|
44
|
+
salt: salt,
|
|
45
|
+
info: info,
|
|
46
|
+
},
|
|
47
|
+
key,
|
|
48
|
+
length,
|
|
49
|
+
),
|
|
50
|
+
);
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
verify() {
|
|
54
|
+
// We do not really verify anything
|
|
55
|
+
return;
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
mock: true,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export function cryptoSetup(Crypto: any) {
|
|
62
|
+
try {
|
|
63
|
+
Crypto.get();
|
|
64
|
+
} catch (e) {
|
|
65
|
+
if ((e as Error).constructor.name !== "NoProviderError") {
|
|
66
|
+
throw e;
|
|
67
|
+
}
|
|
68
|
+
Crypto.get = () => TheCrypto;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2024 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import colors from "ansi-colors";
|
|
8
|
+
|
|
9
|
+
interface LoggerLike {
|
|
10
|
+
format: string;
|
|
11
|
+
log(level: number, message: string): void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface MockLogger {
|
|
15
|
+
emitAll: boolean;
|
|
16
|
+
injectExternalMessage: (source: string, text: string) => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const TheMockLogger: MockLogger = {
|
|
20
|
+
emitAll: false,
|
|
21
|
+
injectExternalMessage: (source: string, text: string) => console.log(formatExternalMessage(source, text)),
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
function formatExternalMessage(source: string, text: string) {
|
|
25
|
+
return ` ${colors.bgCyan.black.bold(` ${source} `)} ${colors.dim(text)}`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* These functions are invoked by beforeEach/afterEach handlers in generalSetup for Mocha.
|
|
30
|
+
*
|
|
31
|
+
* We place them in an array here rather than calling the global hook functions so that load order doesn't matter. We
|
|
32
|
+
* use an array so that if multiple Logger classes are created (e.g. one for CJS and one for ESM) we don't have to worry
|
|
33
|
+
* about which logger is doing the logging.
|
|
34
|
+
*/
|
|
35
|
+
export const LoggerHooks = {
|
|
36
|
+
beforeEach: Array<(mocha: Mocha) => void>(),
|
|
37
|
+
afterEach: Array<(mocha: Mocha) => void>(),
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export function loggerSetup(Logger: LoggerLike) {
|
|
41
|
+
// Currently everywhere we run tests supports ANSI escape codes for
|
|
42
|
+
// colorization. This includes:
|
|
43
|
+
//
|
|
44
|
+
// - Node console
|
|
45
|
+
// - Github actions
|
|
46
|
+
// - Headless browser -> node console
|
|
47
|
+
// - VS code/webstorm terminal
|
|
48
|
+
//
|
|
49
|
+
// Should this become a PITA we can add an option to disable
|
|
50
|
+
Logger.format = "ansi";
|
|
51
|
+
|
|
52
|
+
let messageBuffer: [number, string][] | undefined;
|
|
53
|
+
|
|
54
|
+
const defaultLog = Logger.log;
|
|
55
|
+
|
|
56
|
+
function passMessage(args: [number, string]) {
|
|
57
|
+
defaultLog.apply(Logger, args);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function interceptingLogger(...args: [number, string]) {
|
|
61
|
+
let emitAll = TheMockLogger.emitAll;
|
|
62
|
+
if (MatterHooks?.loggerSink) {
|
|
63
|
+
MatterHooks.loggerSink(...args);
|
|
64
|
+
} else if (!emitAll) {
|
|
65
|
+
if (messageBuffer) {
|
|
66
|
+
messageBuffer.push(args);
|
|
67
|
+
} else {
|
|
68
|
+
emitAll = true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (emitAll) {
|
|
73
|
+
passMessage(args);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
TheMockLogger.injectExternalMessage = (source, text) => interceptingLogger(0, formatExternalMessage(source, text));
|
|
78
|
+
|
|
79
|
+
Logger.log = interceptingLogger;
|
|
80
|
+
|
|
81
|
+
// Divert log messages for test duration
|
|
82
|
+
LoggerHooks.beforeEach.push(function () {
|
|
83
|
+
if (!TheMockLogger.emitAll) {
|
|
84
|
+
messageBuffer = [];
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// Emit log messages only if the test fails
|
|
89
|
+
LoggerHooks.afterEach.push(mocha => {
|
|
90
|
+
if (messageBuffer?.length) {
|
|
91
|
+
if (mocha.suite.ctx.currentTest?.isFailed()) {
|
|
92
|
+
for (const args of messageBuffer) {
|
|
93
|
+
passMessage(args);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
messageBuffer = undefined;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|