-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(support): Vitest plugin * Document usage with Vitest * Fix local tests env and plugin * Fix native mocks on Vitest * Add build to CI workflow
- Loading branch information
Showing
21 changed files
with
247 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./dist/register"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,10 @@ | ||
import { Image } from "react-native"; | ||
|
||
import { noop } from "../../helpers/commons"; | ||
import { mockComponent } from "../../helpers/mockComponent"; | ||
import { imageMethodsMock } from "../../helpers/nativeMethodsMock"; | ||
|
||
import type { ComponentClass } from "react"; | ||
|
||
export type ImageMethods = Partial<typeof Image>; | ||
|
||
export const imageMethodsMock: ImageMethods = { | ||
getSize: noop, | ||
getSizeWithHeaders: noop, | ||
prefetch: () => Promise.resolve(false), | ||
prefetchWithMetadata: () => Promise.resolve(false), | ||
queryCache: () => Promise.resolve({ }), | ||
resolveAssetSource: () => ({ | ||
height: 0, | ||
scale: 0, | ||
uri: "", | ||
width: 0, | ||
}), | ||
}; | ||
|
||
const Mock = mockComponent(Image as ComponentClass); | ||
|
||
export const ImageMock = Object.assign(Mock, imageMethodsMock); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,6 @@ | ||
import { type HostComponent, type NativeMethods, TextInput } from "react-native"; | ||
import { TextInput } from "react-native"; | ||
|
||
import { noop } from "../../helpers/commons"; | ||
import { mockComponent } from "../../helpers/mockComponent"; | ||
import { nativeMethodsMock } from "../../helpers/nativeMethodsMock"; | ||
|
||
import type { ElementRef } from "react"; | ||
|
||
export type TextInputMethods = NativeMethods | TextInput & { | ||
getNativeRef: () => ElementRef<HostComponent<unknown>> | undefined; | ||
}; | ||
|
||
export const textInputMethodsMock: TextInputMethods = { | ||
...nativeMethodsMock, | ||
clear: noop, | ||
getNativeRef: () => undefined, | ||
isFocused: () => false, | ||
setSelection: noop, | ||
}; | ||
import { textInputMethodsMock } from "../../helpers/nativeMethodsMock"; | ||
|
||
export const TextInputMock = mockComponent(TextInput, textInputMethodsMock); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { mockNative, restoreNativeMocks } from "./lib/mockNative"; | ||
|
||
export type { NativeBase, NativeKey } from "./lib/mockNative"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { name } from "../../package.json"; | ||
|
||
import type { Environment } from "vitest"; | ||
|
||
const reactNativeEnv: Environment = { | ||
name: "react-native", | ||
setup: async () => { | ||
await import(`${name}/register`); | ||
|
||
return { teardown: () => undefined }; | ||
}, | ||
transformMode: "ssr", | ||
}; | ||
|
||
export default reactNativeEnv; |
Oops, something went wrong.