Skip to content

Commit

Permalink
v1 (#456)
Browse files Browse the repository at this point in the history
* refactor: rename `meassurePerformance` to `measureRenders` (#433)

* chore: v1.0.0-beta

* docs: update changelogs

* docs: migration guide

* chore: update snapshots

* chore: update node ver on GH

* chore: v1.0.0-rc

* chore: v1.0.0-rc.1

* chore: reorganize repo deps (#477)

* refactor: migrate deps

* chore: dedup eslint

* chore: fix eslint deps

* chore: yarn berry (#478)

* chore: yarn berry (wip)

chore: forward reassure cli in the main package

chore: remove --force

chore: fix ci

chore: fix ci

chore: fix typecheck

chore: fix danger

chore: fix danger

chore: fix ci

chore: fix danger

refactor: tweaks

* chore: workspace deps

* chore: add changeset

* chore: v1.0.0-rc.2

* chore: fix versions

* chore: fix version deps between packages

* chore: v1.0.0-rc.3

* fix: iso date milliseconds regex (#481)

* chore: check deps consistency (#482)

* chore: pdate deps 2024-05-09 (#484)

* chore: update deps

* chore: fix lint

* chore: update danger (#483)

chore: update danger.js

* chore: upgrade RN / test app (#485)

* chore: upgrade turbo

* chore: update React Native / test app

* chore: fix wasm error

* chore: updata other deps (#486)

* chore: update other deps

* chore: update peer deps

* chore: update deps

* feat: enable wasm by default (#488)

* chore: tweak workflow (#490)

* chore: tweak workflow

* chore: update docs

* chore: export types (#489)

* chore: export types

* chore: gen yarn.lock

* chore: tweaks docs

* refactor: rename types

* chore: add docs

* chore: clean scripts (#491)

* chore: clean scripts

* chore: tweak turbo

* chore: add missing changeset

* chore: v1.0.0-beta.4

* chore: regenerate yarn.lock

* feat: detect unnecessary render and warn user (#468)

* feat: detect unnecessary render and warn user

feat: capture json representations in an array to compare after for unnecessary rendering

fix: get current testingLibrary for comparasion only react-native for now

fix: save json representation instead of string for rendered component state and compare changes between states using dfs

fix: test name

fix: update comparasion function and save compare results into output.json and show comparation results in the end of the test

fix: update interface and variable names based on pr recommendatations

chore: rebase to v1

* refactor: improve output formatting

* refactor: fix typo

* refactor: remove unnecessary warning

* refactor: improve testing

* refactor: improve report criteria

* refactor: improve naming

* refactor: improve code structure & tests

* refactor: tweaks

* feat: improve markdown output

* refactor: custom tree comparer

* refactor: clean up code

* refactor: update JSON structure

* refactor: use "initial update count" naming

* chore: fix lint

* chore: improve tests

* refactor: tweaks

* docs: update

* refactor: self code review

* docs: tweaks

* chore: add changeset

* refactor: final tweaks

---------

Co-authored-by: Guven Karanfil <guven.karanfil@smartface.io>
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>

* chore: v1.0.0-rc.5

* chore: fix yarn.lock

* chore: fix reassure-tests.sh

---------

Co-authored-by: Güven Karanfil <40958989+guvenkaranfil@users.noreply.github.com>
Co-authored-by: Guven Karanfil <guven.karanfil@smartface.io>
  • Loading branch information
3 people committed Jun 16, 2024
1 parent 3e6e6a4 commit ebcf9d6
Show file tree
Hide file tree
Showing 82 changed files with 26,944 additions and 17,711 deletions.
11 changes: 11 additions & 0 deletions .changeset/fluffy-papayas-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'reassure': minor
'@callstack/reassure-compare': minor
'@callstack/reassure-measure': minor
'test-app-native': minor
'@callstack/reassure-danger': minor
'@callstack/reassure-logger': minor
'@callstack/reassure-cli': minor
---

chore: migrate to Yarn Berry (4.x)
11 changes: 11 additions & 0 deletions .changeset/gold-bulldogs-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'reassure': minor
'@callstack/reassure-compare': minor
'@callstack/reassure-measure': minor
'test-app-native': minor
'@callstack/reassure-danger': minor
'@callstack/reassure-logger': minor
'@callstack/reassure-cli': minor
---

chore: fix version deps
8 changes: 8 additions & 0 deletions .changeset/hot-ties-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'reassure': minor
'@callstack/reassure-compare': minor
'@callstack/reassure-measure': minor
'@callstack/reassure-cli': minor
---

Detect render issues (initial render updates, redundant renders)
6 changes: 6 additions & 0 deletions .changeset/lemon-peas-shop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'reassure': minor
'@callstack/reassure-cli': minor
---

`reassure` enables WASM support by default and runs using v8 baseline compilers: sparkplug and liftoff (WASM)
19 changes: 19 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"mode": "pre",
"tag": "next",
"initialVersions": {
"@callstack/reassure-cli": "1.0.0-rc.1",
"@callstack/reassure-compare": "1.0.0-rc.1",
"@callstack/reassure-danger": "1.0.0-rc.1",
"@callstack/reassure-logger": "1.0.0-rc.1",
"@callstack/reassure-measure": "1.0.0-rc.1",
"reassure": "1.0.0-rc.1",
"ReassureNativeTester": "1.0.0-rc.1"
},
"changesets": [
"fluffy-papayas-reply",
"gold-bulldogs-work",
"hot-ties-double",
"lemon-peas-shop"
]
}
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
rules: {
'require-await': 'error',
},
ignorePatterns: ['docusaurus/**'],
ignorePatterns: ['docusaurus/**', 'test-apps/**'],
overrides: [
{
files: ['*.ts', '*.tsx'],
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/docs-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,20 @@ jobs:
name: Deploy to GitHub Pages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Checkout
uses: actions/checkout@v4

- name: Enable Corepack
run: corepack enable

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
cache: yarn

- name: Install dependencies
run: cd ./docusaurus && yarn install --frozen-lockfile
run: cd ./docusaurus && yarn install --immutable
- name: Build website
run: cd ./docusaurus && yarn build

Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Enable Corepack
run: corepack enable

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 20.x
cache: 'yarn'

- name: Install and build
run: yarn install --force

- name: Install Docusaurus modules
run: cd ./docusaurus && yarn install --force
run: yarn install --immutable

- name: Validate TypeScript
run: yarn typecheck && yarn typecheck:test-app

- name: Validate ESLint
run: yarn lint
run: yarn lint && yarn lint:deps

- name: Run tests
run: yarn test && yarn test:test-app
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/stability.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Enable Corepack
run: corepack enable

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 20.x
cache: 'yarn'

- name: Install and build
run: yarn install --force
run: yarn install

- name: Run stability checks
run: cd test-apps/native && yarn reassure check-stability
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ project.xcworkspace
local.properties
android.iml

# Yarn
.yarn/*
!.yarn/cache
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# Cocoapods
#
test-apps/native/ios/Pods
Expand Down
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ Now that the library is installed, you can write your first test scenario in a f

```ts
// ComponentUnderTest.perf-test.tsx
import { measurePerformance } from 'reassure';
import { measureRenders } from 'reassure';
import { ComponentUnderTest } from './ComponentUnderTest';

test('Simple test', async () => {
await measurePerformance(<ComponentUnderTest />);
await measureRenders(<ComponentUnderTest />);
});
```

Expand All @@ -128,7 +128,7 @@ This test will measure render times of `ComponentUnderTest` during mounting and
If your component contains any async logic or you want to test some interaction, you should pass the `scenario` option:

```ts
import { measurePerformance } from 'reassure';
import { measureRenders } from 'reassure';
import { screen, fireEvent } from '@testing-library/react-native';
import { ComponentUnderTest } from './ComponentUnderTest';

Expand All @@ -138,7 +138,7 @@ test('Test with scenario', async () => {
await screen.findByText('Done');
};

await measurePerformance(<ComponentUnderTest />, { scenario });
await measureRenders(<ComponentUnderTest />, { scenario });
});
```

Expand All @@ -147,7 +147,7 @@ The body of the `scenario` function is using familiar React Native Testing Libra
In case of using a version of React Native Testing Library lower than v10.1.0, where [`screen` helper](https://callstack.github.io/react-native-testing-library/docs/api/#screen) is not available, the `scenario` function provides it as its first argument:

```ts
import { measurePerformance } from 'reassure';
import { measureRenders } from 'reassure';
import { fireEvent } from '@testing-library/react-native';

test('Test with scenario', async () => {
Expand All @@ -156,7 +156,7 @@ test('Test with scenario', async () => {
await screen.findByText('Done');
};

await measurePerformance(<ComponentUnderTest />, { scenario });
await measureRenders(<ComponentUnderTest />, { scenario });
});
```

Expand Down Expand Up @@ -192,19 +192,19 @@ A simple version of such script, using a branch-changing approach, is as follows
#!/usr/bin/env bash
set -e

BASELINE_BRANCH=${BASELINE_BRANCH:="main"}
BASELINE_BRANCH=${GITHUB_BASE_REF:="main"}

# Required for `git switch` on CI
git fetch origin

# Gather baseline perf measurements
git switch "$BASELINE_BRANCH"
yarn install --force
yarn install
yarn reassure --baseline

# Gather current perf measurements & compare results
git switch --detach -
yarn install --force
yarn install
yarn reassure
```

Expand Down Expand Up @@ -265,19 +265,19 @@ A simple version of such script, using a branch-changing approach, is as follows
#!/usr/bin/env bash
set -e

BASELINE_BRANCH=${BASELINE_BRANCH:="main"}
BASELINE_BRANCH=${GITHUB_BASE_REF:="main"}

# Required for `git switch` on CI
git fetch origin

# Gather baseline perf measurements
git switch "$BASELINE_BRANCH"
yarn install --force
yarn install
yarn reassure --baseline

# Gather current perf measurements & compare results
git switch --detach -
yarn install --force
yarn install
yarn reassure
```

Expand Down Expand Up @@ -362,23 +362,23 @@ Looking at the example, you can notice that test scenarios can be assigned to ce

### Measurements

#### `measurePerformance` function
#### `measureRenders` function

Custom wrapper for the RNTL `render` function responsible for rendering the passed screen inside a `React.Profiler` component,
measuring its performance and writing results to the output file. You can use the optional `options` object that allows customizing aspects
of the testing

```ts
async function measurePerformance(
async function measureRenders(
ui: React.ReactElement,
options?: MeasureOptions,
options?: MeasureRendersOptions,
): Promise<MeasureResults> {
```
#### `MeasureOptions` type
#### `MeasureRendersOptions` type
```ts
interface MeasureOptions {
interface MeasureRendersOptions {
runs?: number;
warmupRuns?: number;
wrapper?: React.ComponentType<{ children: ReactElement }>;
Expand Down Expand Up @@ -461,10 +461,10 @@ function configure(customConfig: Partial<Config>): void;
The `configure` function can override the default config parameters.
#### `resetToDefault` function
#### `resetToDefaults` function
```ts
resetToDefault(): void
resetToDefaults(): void
```
Reset the current config to the original `defaultConfig` object
Expand Down
10 changes: 10 additions & 0 deletions docusaurus/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,13 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Yarn
.yarn/*
!.yarn/cache
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

20 changes: 10 additions & 10 deletions docusaurus/docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ sidebar_position: 4

## Measurements

### `measurePerformance()` function {#measure-renders}
### `measureRenders()` function {#measure-renders}

:::info

Expand All @@ -20,17 +20,17 @@ measuring its performance and writing results to the output file. You can use op
of the testing.

```ts
async function measurePerformance(
async function measureRenders(
ui: React.ReactElement,
options?: MeasureOptions,
options?: MeasureRendersOptions,
): Promise<MeasureResults> {
```
#### Example {#measure-renders-example}
```ts
// sample.perf-test.tsx
import { measurePerformance } from 'reassure';
import { measureRenders } from 'reassure';
import { screen, fireEvent } from '@testing-library/react-native';
import { ComponentUnderTest } from './ComponentUnderTest';

Expand All @@ -40,14 +40,14 @@ test('Test with scenario', async () => {
await screen.findByText('Done');
};

await measurePerformance(<ComponentUnderTest />, { scenario });
await measureRenders(<ComponentUnderTest />, { scenario });
});
```
### `MeasureOptions` type {#measure-renders-options}
### `MeasureRendersOptions` type {#measure-renders-options}
```ts
interface MeasureOptions {
interface MeasureRendersOptions {
runs?: number;
warmupRuns?: number;
wrapper?: React.ComponentType<{ children: ReactElement }>;
Expand Down Expand Up @@ -154,13 +154,13 @@ configure({
});
```
### `resetToDefault` function {#reset-to-defaults}
### `resetToDefaults` function {#reset-to-defaults}
```ts
resetToDefault(): void
resetToDefaults(): void
```
Reset current config to the original `defaultConfig` object. You can call `resetToDefault()` anywhere in your performance test file.
Reset current config to the original `defaultConfig` object. You can call `resetToDefaults()` anywhere in your performance test file.
### Environmental variables
Expand Down
Loading

0 comments on commit ebcf9d6

Please sign in to comment.