-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(component-testing): implement mocks #1027
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
|
@@ -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": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In order to correctly set paths to types |
||
"*": { | ||
"index": [ | ||
"build/src/index.d.ts" | ||
], | ||
"mock": [ | ||
"build/src/mock/index.d.ts" | ||
] | ||
} | ||
}, | ||
"homepage": "https://testplane.io/", | ||
"engines": { | ||
"node": ">= 18.0.0" | ||
|
@@ -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", | ||
|
@@ -81,6 +95,7 @@ | |
"mocha": "10.2.0", | ||
"plugins-loader": "1.3.4", | ||
"png-validator": "1.1.0", | ||
"recast": "0.23.6", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Used in browser env in order to correctly modify ast tree to correctly work with mock |
||
"resolve.exports": "2.0.2", | ||
"sharp": "0.32.6", | ||
"sizzle": "2.3.6", | ||
|
@@ -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", | ||
|
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'); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After that, people wouldn't have ability to import from somewhere else
Maybe we could get rid of it, return "main" and export "mock" from "testplane" so we could do this:
or something like that.
I think we shouldn't define
exports
section in package.json untiltestplane@9