Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"npmClient": "yarn",
"version": "1.4.3",
"version": "1.4.4-alpha.1",
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"command": {
"publish": {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sherlo",
"version": "1.4.3",
"version": "1.4.4-alpha.1",
"description": "Sherlo CLI for React Native Storybook visual testing",
"keywords": [
"visual testing",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version": "1.4.3"}
{"version": "1.4.4-alpha.1"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version": "1.4.3"}
{"version": "1.4.4-alpha.1"}
6 changes: 2 additions & 4 deletions packages/react-native-storybook/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sherlo/react-native-storybook",
"version": "1.4.3",
"version": "1.4.4-alpha.1",
"description": "Sherlo is a Visual Testing tool for React Native Storybook",
"keywords": [
"visual testing",
Expand Down Expand Up @@ -58,13 +58,11 @@
"base-64": "^0.1.0",
"deepmerge": "4.3.1",
"its-fine": "^2.0.0",
"sherlo": "^1.4.3",
"utf8": "^3.0.0"
},
"devDependencies": {
"@storybook/react-native": "8.6.2",
"@storybook/react-native": "9.1.2",
"@types/base-64": "^1.0.0",
"@types/node-forge": "^1.3.2",
"@types/utf8": "^3.0.1",
"react-native-safe-area-context": "4.11.0",
"typescript": "^5.3.3"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Theme } from '@storybook/react-native-theming';
import type { Theme } from '@storybook/react-native-theming';
import { View } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { VERIFICATION_TEST_ID } from '../../../constants';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { start } from '@storybook/react-native';
import { useEffect } from 'react';
import { RunnerBridge } from '../../../../helpers';
import SherloModule from '../../../../SherloModule';
import prepareSnapshots from './prepareSnapshots';
import { isStorybook7 } from '../../../helpers';
import { StorybookView } from '../../../../types';

function useSetInitialTestingData({ view }: { view: ReturnType<typeof start> }): void {
function useSetInitialTestingData({ view }: { view: StorybookView }): void {
const lastState = SherloModule.getLastState();

useEffect(() => {
Expand All @@ -26,14 +26,15 @@ function useSetInitialTestingData({ view }: { view: ReturnType<typeof start> }):
snapshots: allStories,
});
})();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
}

export default useSetInitialTestingData;

/* ========================================================================== */

async function waitForStorybookReady(view: ReturnType<typeof start>): Promise<boolean> {
async function waitForStorybookReady(view: StorybookView): Promise<boolean> {
while (true) {
const isReady = Object.keys(view._idToPrepared).length > 0;

Expand Down

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions packages/react-native-storybook/src/types/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { start } from '@storybook/react-native';
import type { View } from '@storybook/react-native';
export interface SherloParameters {
/**
* Setting exclude to true skips the story during testing. This might be
Expand Down Expand Up @@ -44,7 +44,7 @@ export type Snapshot = {

export type SnapshotMode = 'deviceHeight' | 'fullHeight';

export type StorybookView = ReturnType<typeof start>;
export type StorybookView = View;

type StorybookParamsRaw = Parameters<StorybookView['getStorybookUI']>[0];
export type StorybookParams = StorybookParamsRaw extends infer U
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// .storybook/main.ts
// .rnstorybook/main.ts
import type { StorybookConfig } from '@storybook/react-native';

const main: StorybookConfig = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* do not change this file, it is auto generated by storybook. */

import { start, updateView } from "@storybook/react-native";
import { start, updateView, View } from '@storybook/react-native';

import "@storybook/addon-ondevice-notes/register";
import "@storybook/addon-ondevice-controls/register";
Expand All @@ -12,40 +11,43 @@ const normalizedStories = [
titlePrefix: "",
directory: "./src",
files: "**/*.stories.?(ts|tsx|js|jsx)",
importPathMatcher:
/^\.(?:(?:^|\/|(?:(?:(?!(?:^|\/)\.).)*?)\/)(?!\.)(?=.)[^/]*?\.stories\.(?:ts|tsx|js|jsx)?)$/,
importPathMatcher: /^\.(?:(?:^|\/|(?:(?:(?!(?:^|\/)\.).)*?)\/)(?!\.)(?=.)[^/]*?\.stories\.(?:ts|tsx|js|jsx)?)$/,
// @ts-ignore
req: require.context(
"../src",
'../src',
true,
/^\.(?:(?:^|\/|(?:(?:(?!(?:^|\/)\.).)*?)\/)(?!\.)(?=.)[^/]*?\.stories\.(?:ts|tsx|js|jsx)?)$/
),
},
}
];


declare global {
var view: ReturnType<typeof start>;
var view: View;
var STORIES: typeof normalizedStories;
}


const annotations = [
require("./preview"),
require("@storybook/react-native/preview"),
require("@storybook/addon-ondevice-actions/preview"),
require('./preview'),
require("@storybook/react-native/preview")
];

global.STORIES = normalizedStories;

// @ts-ignore
module?.hot?.accept?.();



if (!global.view) {
global.view = start({
annotations,
storyEntries: normalizedStories,

});
} else {
updateView(global.view, annotations, normalizedStories);
}

export const view = global.view;
export const view: View = global.view;
2 changes: 1 addition & 1 deletion testing/expo-storybook-8/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { isStorybookMode, addStorybookToDevMenu } from '@sherlo/react-native-storybook';
import { StatusBar } from 'expo-status-bar';
import Storybook from './.storybook';
import Storybook from './.rnstorybook';
import HomeScreen from './src/HomeScreen';

addStorybookToDevMenu();
Expand Down
2 changes: 1 addition & 1 deletion testing/expo-storybook-8/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ const customConfig = {
// Apply Storybook wrapper to the extended config
module.exports = withStorybook(customConfig, {
enabled: true,
configPath: path.resolve(__dirname, './.storybook'),
configPath: path.resolve(__dirname, './.rnstorybook'),
});
12 changes: 6 additions & 6 deletions testing/expo-storybook-8/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,16 @@
"@babel/core": "^7.20.0",
"@expo/config-plugins": "^8.0.0",
"@sherlo/react-native-storybook": "portal:../../packages/react-native-storybook",
"@storybook/addon-ondevice-actions": "^8.3.9",
"@storybook/addon-ondevice-backgrounds": "^8.3.9",
"@storybook/addon-ondevice-controls": "^8.3.9",
"@storybook/addon-ondevice-notes": "^8.3.9",
"@storybook/react-native": "^8.3.9",
"@storybook/addon-ondevice-actions": "^9.1.2",
"@storybook/addon-ondevice-backgrounds": "^9.1.2",
"@storybook/addon-ondevice-controls": "^9.1.2",
"@storybook/addon-ondevice-notes": "^9.1.2",
"@storybook/react-native": "^9.1.2",
"@types/lodash": "^4",
"babel-loader": "^8.2.3",
"burnt": "^0.13.0",
"eas-cli": "16.3.2",
"storybook": "^8.3.9",
"storybook": "^9.1.2",
"typescript": "~5.8.3"
},
"resolutions": {
Expand Down
Loading