Skip to content

Commit

Permalink
feat(component-testing): implement mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
DudaGod committed Nov 6, 2024
1 parent c2af168 commit f503bf5
Show file tree
Hide file tree
Showing 19 changed files with 1,578 additions and 54 deletions.
106 changes: 106 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 17 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "testplane",
"version": "8.20.5",
"description": "Tests framework based on mocha and wdio",
"main": "build/src/index.js",
"files": [
"build",
"typings"
Expand Down Expand Up @@ -34,6 +33,20 @@
"type": "git",
"url": "git://github.com/gemini-testing/testplane.git"
},
"exports": {
".": "./build/src/index.js",
"./mock": "./build/src/mock/index.js"
},
"typesVersions": {
"*": {
"index": [
"build/src/index.d.ts"
],
"mock": [
"build/src/mock/index.d.ts"
]
}
},
"homepage": "https://testplane.io/",
"engines": {
"node": ">= 18.0.0"
Expand All @@ -56,6 +69,7 @@
"@jspm/core": "2.0.1",
"@types/debug": "4.1.12",
"@types/yallist": "4.0.4",
"@vitest/spy": "2.1.4",
"@wdio/globals": "8.39.0",
"@wdio/protocols": "8.38.0",
"@wdio/types": "8.39.0",
Expand All @@ -81,6 +95,7 @@
"mocha": "10.2.0",
"plugins-loader": "1.3.4",
"png-validator": "1.1.0",
"recast": "0.23.6",
"resolve.exports": "2.0.2",
"sharp": "0.32.6",
"sizzle": "2.3.6",
Expand All @@ -90,6 +105,7 @@
"strftime": "0.10.2",
"strip-ansi": "6.0.1",
"temp": "0.8.3",
"tinyspy": "3.0.2",
"urijs": "1.19.11",
"url-join": "4.0.1",
"vite": "5.1.6",
Expand Down
19 changes: 19 additions & 0 deletions src/mock/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export * from "./vitest-spy";
import { isRunInBrowserEnv } from "../utils/browser";

// TODO: use from browser code when migrate to esm
type MockFactory = (originalImport?: unknown) => Promise<unknown>;

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function mock(_moduleName: string, _factory?: MockFactory): void {
if (!isRunInBrowserEnv()) {
throw new Error('"mock" method is available only in browser environment');
}
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function unmock(_moduleName: string): void {
if (!isRunInBrowserEnv()) {
throw new Error('"unmock" method is available only in browser environment');
}
}
Loading

0 comments on commit f503bf5

Please sign in to comment.