Skip to content

Commit 34d6b0b

Browse files
adameichelkrautgithub_actions
authored andcommitted
feat: wait for stable
* revamped logging to cut out playwright noise * moved storyshots to runtime
1 parent 0b6ce64 commit 34d6b0b

35 files changed

+941
-222
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
**/node_modules/
22
**/storybook-static/
33
**/test-results/
4-
test-results-local/
4+
test-results-local/
5+
runtime/out/
6+
runtime-logs-server/out/

Dockerfile.storyshots

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
1-
FROM mcr.microsoft.com/playwright:v1.29.1-focal as final
1+
FROM mcr.microsoft.com/playwright:v1.37.1-focal as final
22

33
RUN useradd -ms /bin/bash playwright-user
44
RUN mkdir -p /storyshots
55
RUN chown playwright-user /storyshots
66
RUN npm install -g pnpm@8
7+
RUN npm config --global set update-notifier false
78

8-
COPY playwright.config.storyshots.ts /storyshots
9-
COPY playwright.config.findStories.ts /storyshots
10-
COPY storyshots.findStories.ts /storyshots
11-
COPY storyshots.spec.ts /storyshots
12-
COPY storyshots.testStories.ts /storyshots
13-
COPY storyshots.testStory.ts /storyshots
14-
COPY storyshots.env.ts /storyshots
15-
COPY storyshots.executionContext.ts /storyshots
16-
COPY storyshots.types.ts /storyshots
17-
COPY storyshots.run.sh /storyshots
18-
COPY storyshots.update.sh /storyshots
9+
WORKDIR /storyshots
1910
COPY package.json /storyshots
2011
COPY pnpm-lock.yaml /storyshots
21-
22-
WORKDIR /storyshots
2312
RUN pnpm install --frozen-lockfile
2413

14+
COPY runtime /storyshots/runtime
15+
COPY runtime-logs-server /storyshots/runtime-logs-server
16+
17+
RUN pnpm compile
18+
2519
USER playwright-user
2620

27-
CMD /storyshots/storyshots.run.sh
21+
CMD /storyshots/runtime/scripts/storyshots.run.sh

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ To include in a `batect.yml`, you need to add the following block:
1111
include:
1212
- type: git
1313
repo: https://github.com/compoze-labs/storyshots.git
14-
ref: 0.8.1
14+
ref: 0.9.0
1515
```
1616
1717
Once included, you will now have access to two tasks: `./batect storyshots` and `./batect storyshots-update`. However, these two commands will also need to know where to find your pre-built Storybook directory:
@@ -66,4 +66,13 @@ Sometimes, stories can just be too fiddly to visually regression test. In these
6666
]
6767
}
6868
```
69-
> You will still see it in the output, labelled as ignored via configuration.
69+
> You will still see it in the output, labelled as ignored via configuration.
70+
71+
## Waiting for Stable
72+
Animations can get us really pitted sometimes. In order to avoid flaky tests, we can wait for a "stable" state of the component before taking a screenshot. "Stable" is defined as the component not changing for a certain amount of time. To configure this, you can add the following to your `.storyshots.config.json`:
73+
```json
74+
{
75+
"waitUntilStableMillis": 1000
76+
}
77+
```
78+
> This example waits up to 1 second for the component to be in a stable state.

batect-bundle.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ config_variables:
1414

1515
containers:
1616
storyshots:
17-
image: eichelkrautadam/storyshots:0.8.1
17+
image: eichelkrautadam/storyshots:0.9.0
1818
volumes:
1919
- local: <{batect.project_directory}/<{resultsDirectory}
2020
container: /storyshots/storyshots
@@ -41,13 +41,21 @@ tasks:
4141
- storybook-server
4242
run:
4343
container: storyshots
44+
environment:
45+
DEBUG: ${DEBUG:-}
46+
LOCAL_RESULTS_DIR: <{resultsDirectory}
47+
CONFIG_FILE: <{configPath}
4448

4549
storyshots-update:
4650
dependencies:
4751
- storybook-server
4852
run:
4953
container: storyshots
50-
command: ./storyshots.update.sh
54+
environment:
55+
DEBUG: ${DEBUG:-}
56+
LOCAL_RESULTS_DIR: <{resultsDirectory}
57+
CONFIG_FILE: <{configPath}
58+
command: ./runtime/scripts/storyshots.update.sh
5159

5260
storyshots-list:
5361
dependencies:
@@ -56,4 +64,7 @@ tasks:
5664
container: storyshots
5765
environment:
5866
STORYSHOTS_LIST: true
59-
command: npx playwright test --config=/storyshots/playwright.config.findStories.ts
67+
DEBUG: ${DEBUG:-}
68+
LOCAL_RESULTS_DIR: <{resultsDirectory}
69+
CONFIG_FILE: <{configPath}
70+
command: ./runtime/scripts/storyshots.list.sh

package.json

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,38 @@
77
"author": "",
88
"license": "ISC",
99
"scripts": {
10-
"start": "pnpm build && ./batect --override-image storyshots=local-storyshots storyshots",
11-
"start:single": "pnpm build && STORYSHOTS_STORY=example-button--primary ./batect --override-image storyshots=local-storyshots storyshots",
12-
"start:list": "pnpm build && ./batect --override-image storyshots=local-storyshots storyshots-list",
13-
"start:local": "pnpm build && ./batect --override-image storyshots=local-storyshots --config-vars-file=batect.target-local.yml storyshots",
14-
"start:update": "pnpm build && ./batect --override-image storyshots=local-storyshots storyshots-update",
10+
"local": "./batect --override-image storyshots=local-storyshots",
11+
"start": "pnpm build && pnpm local storyshots",
12+
"start:debug": "pnpm build && DEBUG=true pnpm local storyshots",
13+
"start:single": "pnpm build && STORYSHOTS_STORY=example-button--primary pnpm local storyshots",
14+
"start:list": "pnpm build && pnpm local storyshots-list",
15+
"start:local": "pnpm build && pnpm local --config-vars-file=batect.target-local.yml storyshots",
16+
"start:update": "pnpm build && pnpm local storyshots-update",
17+
"start:update:debug": "pnpm build && DEBUG=true pnpm local storyshots-update",
18+
"compile": "tsc --incremental -p runtime/tsconfig.json && tsc --incremental -p runtime-logs-server/tsconfig.json",
1519
"build": "docker build -t local-storyshots -f Dockerfile.storyshots .",
1620
"test:local": "pnpm build && IMAGE=local-storyshots pnpm test",
17-
"test": "bash shellspec --fail-fast"
21+
"test": "bash shellspec --fail-fast",
22+
"runtime:logs-server": "node runtime-logs-server/out/serve.js",
23+
"runtime:findStories:debug": "playwright test -c runtime/out --config=/storyshots/runtime/out/playwright.config.findStories.js",
24+
"runtime:findStories": "pnpm --silent runtime:findStories:debug > /dev/null 2>&1",
25+
"runtime:start:debug": "playwright test -c runtime/out --config=/storyshots/runtime/out/playwright.config.storyshots.js",
26+
"runtime:start": "pnpm --silent runtime:start:debug > /dev/null 2>&1",
27+
"runtime:updateSnapshots:debug": "pnpm runtime:start:debug --update-snapshots",
28+
"runtime:updateSnapshots": "pnpm --silent runtime:updateSnapshots:debug > /dev/null 2>&1"
1829
},
30+
"type": "module",
1931
"devDependencies": {
20-
"@playwright/test": "^1.29.1",
21-
"@types/node": "^16.18.10"
32+
"@playwright/test": "^1.37.1",
33+
"@types/body-parser": "^1.19.2",
34+
"@types/express": "^4.17.17",
35+
"@types/node": "^16.18.10",
36+
"axios": "^1.5.0",
37+
"body-parser": "^1.20.2",
38+
"chalk": "^5.3.0",
39+
"express": "^4.18.2",
40+
"stdout-update": "^4.0.0",
41+
"tasktree-cli": "^8.0.0",
42+
"typescript": "^5.1.6"
2243
}
2344
}

0 commit comments

Comments
 (0)