Skip to content
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

Introduce file structure to tests #6293

Merged
merged 8 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Component, ReactElement } from 'react';
import { TestRunner } from './TestRunner';
import { TestRunner } from './TestRunner/TestRunner';
import type { TestComponent } from './TestComponent';
import type { SharedValue } from 'react-native-reanimated';
import type { TestConfiguration, TestValue, NullableTestValue, BuildFunction } from './types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { View, StyleSheet, Text, Pressable } from 'react-native';
import type { ReactNode } from 'react';
import React, { useEffect, useRef, useState } from 'react';
import { runTests, configure } from './RuntimeTestsApi';
import { RenderLock } from './SyncUIRunner';
import { RenderLock } from './utils/SyncUIRunner';

export class ErrorBoundary extends React.Component<
{ children: React.JSX.Element | Array<React.JSX.Element> },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { TestCase, TestSuite } from './types';
import type { TestCase, TestSuite } from '../types';

export function assertMockedAnimationTimestamp(timestamp: number | undefined): asserts timestamp is number {
'worklet';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,29 @@ import type {
TestSummary,
TestValue,
TrackerCallCount,
} from './types';
import { DescribeDecorator, TestDecorator } from './types';
import { TestComponent } from './TestComponent';
import { EMPTY_LOG_PLACEHOLDER, applyMarkdown, color, formatString, indentNestingLevel } from './stringFormatUtils';
} from '../types';
import { DescribeDecorator, TestDecorator } from '../types';
import { TestComponent } from '../TestComponent';
import {
EMPTY_LOG_PLACEHOLDER,
applyMarkdown,
color,
formatString,
indentNestingLevel,
} from '../utils/stringFormatUtils';
import type {
SharedValue,
LayoutAnimationStartFunction,
LayoutAnimationType,
SharedTransitionAnimationsValues,
LayoutAnimation,
} from 'react-native-reanimated';
import { Matchers, nullableMatch } from './matchers/Matchers';
import { Matchers, nullableMatch } from '../matchers/Matchers';
import { assertMockedAnimationTimestamp, assertTestCase, assertTestSuite } from './Asserts';
import { createUpdatesContainer } from './UpdatesContainer';
import { makeMutable, runOnJS } from 'react-native-reanimated';
import { RenderLock, SyncUIRunner } from './SyncUIRunner';
export { Presets } from './Presets';
import { RenderLock, SyncUIRunner } from '../utils/SyncUIRunner';
export { Presets } from '../Presets';

let callTrackerRegistryJS: Record<string, number> = {};
const callTrackerRegistryUI = makeMutable<Record<string, number>>({});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { makeMutable } from 'react-native-reanimated';
import type { Operation, OperationUpdate } from './types';
import { isValidPropName } from './types';
import type { MultiViewSnapshot, SingleViewSnapshot } from './matchers/snapshotMatchers';
import { convertDecimalColor } from './util';
import type { TestComponent } from './TestComponent';
import { SyncUIRunner } from './SyncUIRunner';
import type { Operation, OperationUpdate } from '../types';
import { isValidPropName } from '../types';
import type { MultiViewSnapshot, SingleViewSnapshot } from '../matchers/snapshotMatchers';
import type { TestComponent } from '../TestComponent';
import { SyncUIRunner } from '../utils/SyncUIRunner';
import { convertDecimalColor } from '../utils/util';

type JsUpdate = {
tag: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { color } from '../stringFormatUtils';
import { color } from '../utils/stringFormatUtils';
import type { TestCase, TestValue, NullableTestValue } from '../types';
import type { Matcher, MatcherArguments } from './rawMatchers';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cyan, green, red, yellow } from '../stringFormatUtils';
import { cyan, green, red, yellow } from '../utils/stringFormatUtils';
import type { TestValue, TrackerCallCount } from '../types';
import { ComparisonMode } from '../types';
import { getComparator } from './Comparators';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { formatSnapshotMismatch, green, red, yellow } from '../stringFormatUtils';
import { formatSnapshotMismatch, green, red, yellow } from '../utils/stringFormatUtils';
import type { OperationUpdate, Mismatch } from '../types';
import { ComparisonMode, isValidPropName } from '../types';
import { getComparator, getComparisonModeForProp } from './Comparators';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { runOnJS, runOnUI } from 'react-native-reanimated';
import type { LockObject } from './types';
import type { LockObject } from '../types';

class WaitForUnlock {
private _lock: LockObject = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Mismatch, NullableTestValue } from './types';
import type { Mismatch, NullableTestValue } from '../types';

export function indentNestingLevel(nestingLevel: number) {
return ` ${' '.repeat(nestingLevel)}`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import RuntimeTestsRunner from './ReanimatedRuntimeTestsRunner/RuntimeTestsRunner';
import { describe } from './ReanimatedRuntimeTestsRunner/RuntimeTestsApi';
import RuntimeTestsRunner from './ReJest/RuntimeTestsRunner';
import { describe } from './ReJest/RuntimeTestsApi';

export default function RuntimeTestsExample() {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import {
notify,
waitForNotify,
clearRenderOutput,
} from '../ReanimatedRuntimeTestsRunner/RuntimeTestsApi';
} from '../ReJest/RuntimeTestsApi';
import { Snapshots } from './TestsOfTestingFramework.snapshot';
import { ComparisonMode } from '../ReanimatedRuntimeTestsRunner/types';
import { ComparisonMode } from '../ReJest/types';

const AnimatedComponent = () => {
const widthSV = useSharedValue(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,8 @@ import Animated, {
Easing,
useFrameCallback,
} from 'react-native-reanimated';
import {
describe,
expect,
test,
render,
wait,
registerValue,
getRegisteredValue,
} from '../../ReanimatedRuntimeTestsRunner/RuntimeTestsApi';
import { ComparisonMode } from '../../ReanimatedRuntimeTestsRunner/types';
import { describe, expect, test, render, wait, registerValue, getRegisteredValue } from '../../ReJest/RuntimeTestsApi';
import { ComparisonMode } from '../../ReJest/types';

describe('Test measuring component before nad after animation', () => {
const INITIAL_MEASURE = 'INITIAL_MEASURE';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import React, { useEffect } from 'react';
import { View, StyleSheet } from 'react-native';
import Animated, { useSharedValue, useAnimatedStyle, useFrameCallback } from 'react-native-reanimated';
import {
describe,
test,
expect,
render,
getTestComponent,
wait,
useTestRef,
} from '../../ReanimatedRuntimeTestsRunner/RuntimeTestsApi';
import { describe, test, expect, render, getTestComponent, wait, useTestRef } from '../../ReJest/RuntimeTestsApi';

describe('Test *****useFrameCallback*****', () => {
describe('Test _canceling frameCallback_ after predefined time', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
recordAnimationUpdates,
unmockAnimationTimer,
expect,
} from '../../../ReanimatedRuntimeTestsRunner/RuntimeTestsApi';
} from '../../../ReJest/RuntimeTestsApi';
import { Snapshots } from './basic.snapshot';

describe('withDecay animation, test various config', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
unmockAnimationTimer,
expect,
clearRenderOutput,
} from '../../../ReanimatedRuntimeTestsRunner/RuntimeTestsApi';
} from '../../../ReJest/RuntimeTestsApi';

const WIDTH_COMPONENT_ACTIVE_REF = 'WidthComponentActive';
const WIDTH_COMPONENT_PASSIVE_REF = 'WidthComponentPassive';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import {
unmockAnimationTimer,
mockAnimationTimer,
clearRenderOutput,
} from '../../../ReanimatedRuntimeTestsRunner/RuntimeTestsApi';
import type { SingleViewSnapshot } from '../../../ReanimatedRuntimeTestsRunner/matchers/snapshotMatchers';
} from '../../../ReJest/RuntimeTestsApi';
import type { SingleViewSnapshot } from '../../../ReJest/matchers/snapshotMatchers';

enum TestAnimation {
TIMING = 'withTiming',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,9 @@ import Animated, {
Easing,
withDelay,
} from 'react-native-reanimated';
import {
describe,
test,
render,
wait,
useTestRef,
getTestComponent,
expect,
} from '../../../ReanimatedRuntimeTestsRunner/RuntimeTestsApi';
import { describe, test, render, wait, useTestRef, getTestComponent, expect } from '../../../ReJest/RuntimeTestsApi';
import { View, StyleSheet } from 'react-native';
import { ComparisonMode } from '../../../ReanimatedRuntimeTestsRunner/types';
import { ComparisonMode } from '../../../ReJest/types';

type TestCase = {
startValues: [number, number, number];
Expand All @@ -27,7 +19,7 @@ type TestCase = {
animationNumber: number;
};

describe('withSequence animation of number', () => {
describe('withSequence animation of array', () => {
const COMPONENT_REF = {
first: 'firstComponent',
second: 'secondComponent',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
recordAnimationUpdates,
getRegisteredValue,
registerValue,
} from '../../../ReanimatedRuntimeTestsRunner/RuntimeTestsApi';
} from '../../../ReJest/RuntimeTestsApi';
import { Snapshots } from './snapshots.snapshot';

describe(`Cascade of callbacks`, () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
import React, { useEffect } from 'react';
import { View, StyleSheet } from 'react-native';
import Animated, { useSharedValue, withSequence, cancelAnimation, withTiming } from 'react-native-reanimated';
import {
describe,
test,
expect,
render,
wait,
getTestComponent,
useTestRef,
} from '../../../ReanimatedRuntimeTestsRunner/RuntimeTestsApi';
import { ComparisonMode } from '../../../ReanimatedRuntimeTestsRunner/types';
import { describe, test, expect, render, wait, getTestComponent, useTestRef } from '../../../ReJest/RuntimeTestsApi';
import { ComparisonMode } from '../../../ReJest/types';

describe(`Test cancelling animation `, () => {
const COMPONENT_REF = 'COMPONENT_REF';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,17 @@ import Animated, {
withSequence,
withDelay,
} from 'react-native-reanimated';
import {
describe,
test,
render,
wait,
useTestRef,
getTestComponent,
expect,
} from '../../../ReanimatedRuntimeTestsRunner/RuntimeTestsApi';
import { describe, test, render, wait, useTestRef, getTestComponent, expect } from '../../../ReJest/RuntimeTestsApi';
import { View, StyleSheet } from 'react-native';
import { ComparisonMode } from '../../../ReanimatedRuntimeTestsRunner/types';
import { ComparisonMode } from '../../../ReJest/types';

type TestCase = {
startColor: string;
middleColor: string;
finalColor: string;
};

describe('withSequence animation of number', () => {
describe('withSequence animation of color', () => {
enum Component {
ACTIVE = 'ACTIVE',
PASSIVE = 'PASSIVE',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,9 @@ import Animated, {
Easing,
withDelay,
} from 'react-native-reanimated';
import {
describe,
test,
render,
wait,
useTestRef,
getTestComponent,
expect,
} from '../../../ReanimatedRuntimeTestsRunner/RuntimeTestsApi';
import { describe, test, render, wait, useTestRef, getTestComponent, expect } from '../../../ReJest/RuntimeTestsApi';
import { View, StyleSheet } from 'react-native';
import { ComparisonMode } from '../../../ReanimatedRuntimeTestsRunner/types';
import { ComparisonMode } from '../../../ReJest/types';

type TestCase = {
startValue: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
recordAnimationUpdates,
render,
wait,
} from '../../../ReanimatedRuntimeTestsRunner/RuntimeTestsApi';
} from '../../../ReJest/RuntimeTestsApi';
import { Snapshots } from './withSpring.snapshot';

const AnimatedComponent = ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
import React, { useEffect } from 'react';
import { View, StyleSheet } from 'react-native';
import Animated, { useSharedValue, useAnimatedStyle, withTiming, withDelay } from 'react-native-reanimated';
import { ComparisonMode } from '../../../ReanimatedRuntimeTestsRunner/types';
import {
describe,
test,
expect,
render,
useTestRef,
getTestComponent,
wait,
} from '../../../ReanimatedRuntimeTestsRunner/RuntimeTestsApi';
import { ComparisonMode } from '../../../ReJest/types';
import { describe, test, expect, render, useTestRef, getTestComponent, wait } from '../../../ReJest/RuntimeTestsApi';

const COMPONENT_REF = {
first: 'firstComponent',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect } from 'react';
import { View, StyleSheet, Dimensions } from 'react-native';
import Animated, { useSharedValue, useAnimatedStyle, withTiming, withDelay } from 'react-native-reanimated';
import { ComparisonMode } from '../../../ReanimatedRuntimeTestsRunner/types';
import { ComparisonMode } from '../../../ReJest/types';
import {
describe,
test,
Expand All @@ -13,7 +13,7 @@ import {
callTracker,
callTrackerFn,
getTrackerCallCount,
} from '../../../ReanimatedRuntimeTestsRunner/RuntimeTestsApi';
} from '../../../ReJest/RuntimeTestsApi';

enum Tracker {
UseAnimatedStyle = 'useAnimatedStyleTracker',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
import React, { useEffect } from 'react';
import { View, StyleSheet } from 'react-native';
import Animated, { useSharedValue, useAnimatedStyle, withTiming, withDelay } from 'react-native-reanimated';
import { ComparisonMode } from '../../../ReanimatedRuntimeTestsRunner/types';
import {
describe,
test,
expect,
render,
useTestRef,
getTestComponent,
wait,
} from '../../../ReanimatedRuntimeTestsRunner/RuntimeTestsApi';
import { ComparisonMode } from '../../../ReJest/types';
import { describe, test, expect, render, useTestRef, getTestComponent, wait } from '../../../ReJest/RuntimeTestsApi';

const COMPONENT_REF_ACTIVE = 'ColorComponentPassive';
const COMPONENT_REF_PASSIVE = 'ColorComponentPassive';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import {
render,
wait,
unmockAnimationTimer,
} from '../../../ReanimatedRuntimeTestsRunner/RuntimeTestsApi';
} from '../../../ReJest/RuntimeTestsApi';
import { EasingSnapshots } from './withTiming.snapshot';
import { ErrorBoundary } from '../../../ReanimatedRuntimeTestsRunner/RuntimeTestsRunner';
import { ErrorBoundary } from '../../../ReJest/RuntimeTestsRunner';

const ActiveAnimatedComponent = ({ easing }: { easing: EasingFunction | EasingFunctionFactory | undefined }) => {
const widthSV = useSharedValue(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,9 @@ import React, { useEffect } from 'react';
import { View, StyleSheet } from 'react-native';
import type { AnimatableValueObject } from 'react-native-reanimated';
import Animated, { useSharedValue, useAnimatedStyle, withTiming, withDelay } from 'react-native-reanimated';
import type { ValidPropNames } from '../../../ReanimatedRuntimeTestsRunner/types';
import {
describe,
test,
expect,
render,
useTestRef,
getTestComponent,
wait,
} from '../../../ReanimatedRuntimeTestsRunner/RuntimeTestsApi';
import { getComparisonModeForProp } from '../../../ReanimatedRuntimeTestsRunner/matchers/Comparators';
import type { ValidPropNames } from '../../../ReJest/types';
import { describe, test, expect, render, useTestRef, getTestComponent, wait } from '../../../ReJest/RuntimeTestsApi';
import { getComparisonModeForProp } from '../../../ReJest/matchers/Comparators';

const COMPONENT_REF = 'AnimatedComponent';

Expand Down
Loading