Skip to content

Conversation

@lewisl9029
Copy link
Contributor

@lewisl9029 lewisl9029 commented Sep 23, 2023

Summary

Implements Reflame's new testing features. :)

Currently the only kind of test available are component screenshot tests, where you supply a React component/element, and we'll take a screenshot of it every time you push a commit (and later diff it against the last known good version, skip it if its dependencies hasn't changed, etc).

There are two ways to write tests at the moment:

  1. Export a React component or element from any module with a _test postfix (examples here). Anything with a _test postfix will be eliminated in non-testing builds, and then a dead code elimination pass will be performed, so in theory there shouldn't be leakage of testing-only deps from this.

  2. Export a React component or element with any name (except default) from a *.stories.{ts|tsx|js|jsx} file. This enabled through the storybook compat config, and is why all of the stories in @highlight-run/ui are being picked up automatically.

Let me know what you think!

How did you test this change?

Are there any deployment considerations?

Does this work require review from our design team?

Try adding a test
@lewisl9029 lewisl9029 marked this pull request as ready for review September 29, 2023 04:16
@lewisl9029 lewisl9029 changed the title Add tests Add Reflame tests Sep 29, 2023
@Vadman97 Vadman97 enabled auto-merge (squash) September 29, 2023 23:36
@Vadman97 Vadman97 merged commit fdd93db into highlight:main Sep 29, 2023
lewisl9029 added a commit to lewisl9029/highlight that referenced this pull request Nov 16, 2023
Implements Reflame's new testing features. :)

Currently the only kind of test available are component screenshot
tests, where you supply a React component/element, and we'll take a
screenshot of it every time you push a commit (and later diff it against
the last known good version, skip it if its dependencies hasn't changed,
etc).

There are two ways to write tests at the moment:

1. Export a React component or element from any module with a _test
postfix
([examples](https://github.com/highlight/highlight/pull/6699/files#diff-82085b66646a6df6fc80fb2efc545a69271e0f7f28bbb03c6428d44fdaa2bdbbR33)
[here](https://github.com/highlight/highlight/pull/6699/files#diff-0073669d5601b1c655cb637e2d52832d1cce7426584d02315d6df24cc423dc16R20)).
Anything with a _test postfix will be eliminated in non-testing builds,
and then a dead code elimination pass will be performed, so in theory
there shouldn't be leakage of testing-only deps from this.

2. Export a React component or element with any name (except `default`)
from a `*.stories.{ts|tsx|js|jsx}` file. This enabled through the
storybook compat config, and is why all of the stories in
`@highlight-run/ui` are being picked up automatically.

Let me know what you think!

<!--
Frontend - Leave a screencast or a screenshot to visually describe the
changes.
-->

<!--
 Backend - Do we need to consider migrations or backfilling data?
-->

<!--
 Request review from julian-highlight / our design team
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants