Skip to content

Commit eae96ce

Browse files
committed
Update the snapshot infra
1 parent 0df8f24 commit eae96ce

File tree

6 files changed

+43
-34
lines changed

6 files changed

+43
-34
lines changed

packages/typescriptlang-org/backstop.json

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,37 @@
11
{
22
"id": "backstop_default",
33
"viewports": [
4-
{
5-
"label": "phone",
6-
"width": 320,
7-
"height": 480
8-
},
9-
{
10-
"label": "tablet",
11-
"width": 1024,
12-
"height": 768
13-
},
14-
{
15-
"label": "computer",
16-
"width": 1280,
17-
"height": 900
18-
}
4+
{ "label": "phone", "width": 320, "height": 480 },
5+
{ "label": "tablet", "width": 1024, "height": 768 },
6+
{ "label": "computer", "width": 1280, "height": 900 }
197
],
20-
"onBeforeScript": "puppet/onBefore.js",
21-
"onReadyScript": "puppet/onReady.js",
228
"scenarios": [
239
{
2410
"label": "Index",
25-
"url": "file:///Users/ortatherox/dev/typescript/new-website/packages/typescriptlang-org/public/index.html",
11+
"url": "file:///Users/orta/dev/typescript/new-typescript-website/packages/typescriptlang-org/public/index.html",
2612
"misMatchThreshold": 0.1
2713
},
2814
{
2915
"label": "Empty Page",
30-
"url": "file:///Users/ortatherox/dev/typescript/new-website/packages/typescriptlang-org/public/empty/index.html",
16+
"url": "file:///Users/orta/dev/typescript/new-typescript-website/packages/typescriptlang-org/public/empty/index.html",
3117
"misMatchThreshold": 0.1
3218
},
3319
{
3420
"label": "Old Handbook Example",
35-
"url": "file:///Users/ortatherox/dev/typescript/new-website/packages/typescriptlang-org/public/docs/handbook/functions.html",
21+
"url": "file:///Users/orta/dev/typescript/new-typescript-website/packages/typescriptlang-org/public/docs/handbook/functions.html",
3622
"misMatchThreshold": 0.1,
3723
"selectors": ["viewport"]
3824
},
3925
{
4026
"label": "Old Handbook Example Dark",
41-
"url": "file:///Users/ortatherox/dev/typescript/new-website/packages/typescriptlang-org/public/docs/handbook/functions.html",
27+
"url": "file:///Users/orta/dev/typescript/new-typescript-website/packages/typescriptlang-org/public/docs/handbook/functions.html",
4228
"misMatchThreshold": 0.1,
4329
"selectors": ["viewport"],
4430
"onReadyScript": "../../../scripts/backstop/makeDarkMode.js"
4531
},
46-
4732
{
4833
"label": "TSConfig Example",
49-
"url": "file:///Users/ortatherox/dev/typescript/new-website/packages/typescriptlang-org/public/en/tsconfig/index.html",
34+
"url": "file:///Users/orta/dev/typescript/new-typescript-website/packages/typescriptlang-org/public/en/tsconfig/index.html",
5035
"misMatchThreshold": 0.1,
5136
"selectors": ["viewport"]
5237
}
@@ -60,9 +45,7 @@
6045
},
6146
"report": ["browser"],
6247
"engine": "puppeteer",
63-
"engineOptions": {
64-
"args": ["--no-sandbox"]
65-
},
48+
"engineOptions": { "args": ["--no-sandbox"] },
6649
"asyncCaptureLimit": 5,
6750
"asyncCompareLimit": 50,
6851
"debug": false,

packages/typescriptlang-org/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"develop": "gatsby develop",
1010
"clean": "gatsby clean",
1111
"bootstrap": "echo 'NOOP'",
12-
"update-snapshots": "backstop test; backstop approve",
12+
"update-snapshots": "node scripts/updateBackstopJSON.js && backstop test && backstop approve",
1313
"update-static-assets": "node scripts/downloadPlaygroundAssets.js && node scripts/downloadSearchAssets.js",
1414
"start": "npm run develop",
1515
"serve": "gatsby serve",
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module.exports = async (page, scenario) => {
22
console.log("SWITCHING TO DARK for " + scenario.label)
33

4-
await page.emulateMediaFeatures([
5-
{
6-
name: "prefers-color-scheme",
7-
value: "dark",
8-
},
9-
])
10-
await wait()
4+
// await page.emulateMediaFeatures([
5+
// {
6+
// name: "prefers-color-scheme",
7+
// value: "dark",
8+
// },
9+
// ])
10+
// await wait()
1111
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// @ts-check
2+
3+
// The backstop JSON file requires setting the right paths for
4+
// screenshots - this updates them to your computer. A bit lossy
5+
// for the git history but acceptable given that mainly orta will
6+
// be running the snapshots.
7+
8+
const { writeFileSync, readFileSync } = require("fs")
9+
const { join } = require("path")
10+
const { format } = require("prettier")
11+
12+
const backstopPath = join(__dirname, "..", "backstop.json")
13+
const backstopJSON = JSON.parse(readFileSync(backstopPath, "utf8"))
14+
15+
// e.g. file:///Users/ortatherox/dev/typescript/new-website/packages/typescriptlang-org/public/index.html
16+
const newPublicRoot = join(__dirname, "..", "public")
17+
backstopJSON.scenarios.forEach(scenario => {
18+
const fileToCheck = scenario.url.split("/public/")[1]
19+
const newFileURL = `file://${newPublicRoot}/${fileToCheck}`
20+
scenario.url = newFileURL
21+
})
22+
23+
writeFileSync(
24+
backstopPath,
25+
format(JSON.stringify(backstopJSON), { filepath: backstopPath })
26+
)

0 commit comments

Comments
 (0)