Skip to content

Commit 61034b3

Browse files
committed
test: adjust configs
2 parents fd99d0f + b49acda commit 61034b3

File tree

4 files changed

+127
-78
lines changed

4 files changed

+127
-78
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"test.local.desktop.storybook": "wdio tests/configs/wdio.local.desktop.storybook.conf.ts --storybook --numShards=10 --url=https://govuk-react.github.io/govuk-react/ --skipStories=\"/.*(loading-box|spinner).*/\"",
2727
"test.local.desktop.storybook.localhost": "wdio tests/configs/wdio.local.desktop.storybook.conf.ts --storybook --numShards=10",
2828
"test.local.desktop.storybook.localhost.custom": "npm run test.local.desktop.storybook.localhost -- --skipStories='/example-page.*/gm' --spec='tests/specs/storybook-interaction/*.ts'",
29+
"test.local.desktop.storybook.runner": "wdio tests/configs/wdio.local.desktop.storybook.runner.conf.ts",
2930
"test.ocr.local.desktop": "wdio tests/configs/wdio.ocr.local.desktop.conf.ts",
3031
"test.ocr.saucelabs.desktop": "SAUCE=true wdio tests/configs/wdio.ocr.saucelabs.conf.ts",
3132
"test.unit.coverage": "vitest --coverage",
@@ -64,6 +65,7 @@
6465
"@wdio/sauce-service": "^9.0.0-alpha.351",
6566
"@wdio/shared-store-service": "^9.0.0-alpha.351",
6667
"@wdio/spec-reporter": "^9.0.0-alpha.351",
68+
"@wdio/storybook-runner": "workspace:^",
6769
"@wdio/types": "^9.0.0-alpha.351",
6870
"eslint": "^8.57.0",
6971
"eslint-plugin-import": "^2.29.1",
@@ -80,4 +82,4 @@
8082
"vitest": "^1.6.0",
8183
"webdriverio": "^9.0.0-alpha.351"
8284
}
83-
}
85+
}

packages/storybook-runner/src/index.ts

Lines changed: 70 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -33,75 +33,76 @@ export default class StorybookRunner extends LocalRunner {
3333
async initialize() {
3434
log.info('Adding the Visual Service')
3535
const { services } = this.#config
36-
37-
if (services?.flat().includes('visual')) {
38-
log.info('Visual Service is already added')
39-
} else {
40-
this.#config.services = [
41-
...(services ?? []),
42-
[
43-
'visual',
44-
{
45-
46-
}
47-
],
48-
]
49-
}
50-
51-
log.info('Start running Storybook tests')
52-
53-
const { storiesJson, storybookUrl, tempDir } = await scanStorybook(this.#config, this.#options)
54-
// Set an environment variable so it can be used in the onComplete hook
55-
process.env.VISUAL_STORYBOOK_TEMP_SPEC_FOLDER = tempDir
56-
// Add the storybook URL to the environment variables
57-
process.env.VISUAL_STORYBOOK_URL = storybookUrl
58-
59-
// Clear the capabilities
60-
this.#config.capabilities.length = 0
61-
log.info('Clearing the current capabilities.')
62-
63-
// Determine some run options
64-
// --version
65-
const versionOption = this.#options?.version
66-
const versionArgv = getArgvValue('--version', value => Math.floor(parseFloat(value)))
67-
const version = versionOption ?? versionArgv ?? 7
68-
// --numShards
69-
const maxInstances = this.#config?.maxInstances ?? 1
70-
const numShardsOption = this.#options?.numShards
71-
const numShardsArgv = getArgvValue('--numShards', value => parseInt(value, 10))
72-
const numShards = Math.min(numShardsOption || numShardsArgv || NUM_SHARDS, maxInstances)
73-
// --clip
74-
const clipOption = this.#options?.clip
75-
const clipArgv = getArgvValue('--clip', value => value !== 'false')
76-
const clip = clipOption ?? clipArgv ?? true
77-
// --clipSelector
78-
const clipSelectorOption = this.#options?.clipSelector
79-
const clipSelectorArgv = getArgvValue('--clipSelector', value => value)
80-
// V6 has '#root' as the root element, V7 has '#storybook-root'
81-
const clipSelector = (clipSelectorOption ?? clipSelectorArgv) ?? (version === 6 ? V6_CLIP_SELECTOR : CLIP_SELECTOR)
82-
// Add the clip selector to the environment variables
83-
process.env.VISUAL_STORYBOOK_CLIP_SELECTOR = clipSelector
84-
// --skipStories
85-
const skipStoriesOption = this.#options?.skipStories
86-
const skipStoriesArgv = getArgvValue('--skipStories', value => value)
87-
const skipStories = skipStoriesOption ?? skipStoriesArgv ?? []
88-
const parsedSkipStories = parseSkipStories(skipStories)
89-
90-
// Create the test files
91-
createTestFiles({
92-
clip,
93-
clipSelector,
94-
directoryPath: tempDir,
95-
folders: 'this.folders', // Need to get the logic from the Visual service to here
96-
framework: this.#config.framework as string,
97-
numShards,
98-
skipStories: parsedSkipStories,
99-
storiesJson,
100-
storybookUrl,
101-
})
102-
103-
// Create the capabilities
104-
createStorybookCapabilities(this.#config.capabilities as WebdriverIO.Capabilities[])
36+
console.log('this.#config:', this.#config)
37+
38+
// if (services?.flat().includes('visual')) {
39+
// log.info('Visual Service is already added')
40+
// } else {
41+
// this.#config.services = [
42+
// ...(services ?? []),
43+
// [
44+
// 'visual',
45+
// {
46+
47+
// }
48+
// ],
49+
// ]
50+
// }
51+
52+
// log.info('Start running Storybook tests')
53+
54+
// const { storiesJson, storybookUrl, tempDir } = await scanStorybook(this.#config, this.#options)
55+
// // Set an environment variable so it can be used in the onComplete hook
56+
// process.env.VISUAL_STORYBOOK_TEMP_SPEC_FOLDER = tempDir
57+
// // Add the storybook URL to the environment variables
58+
// process.env.VISUAL_STORYBOOK_URL = storybookUrl
59+
60+
// // Clear the capabilities
61+
// this.#config.capabilities.length = 0
62+
// log.info('Clearing the current capabilities.')
63+
64+
// // Determine some run options
65+
// // --version
66+
// const versionOption = this.#options?.version
67+
// const versionArgv = getArgvValue('--version', value => Math.floor(parseFloat(value)))
68+
// const version = versionOption ?? versionArgv ?? 7
69+
// // --numShards
70+
// const maxInstances = this.#config?.maxInstances ?? 1
71+
// const numShardsOption = this.#options?.numShards
72+
// const numShardsArgv = getArgvValue('--numShards', value => parseInt(value, 10))
73+
// const numShards = Math.min(numShardsOption || numShardsArgv || NUM_SHARDS, maxInstances)
74+
// // --clip
75+
// const clipOption = this.#options?.clip
76+
// const clipArgv = getArgvValue('--clip', value => value !== 'false')
77+
// const clip = clipOption ?? clipArgv ?? true
78+
// // --clipSelector
79+
// const clipSelectorOption = this.#options?.clipSelector
80+
// const clipSelectorArgv = getArgvValue('--clipSelector', value => value)
81+
// // V6 has '#root' as the root element, V7 has '#storybook-root'
82+
// const clipSelector = (clipSelectorOption ?? clipSelectorArgv) ?? (version === 6 ? V6_CLIP_SELECTOR : CLIP_SELECTOR)
83+
// // Add the clip selector to the environment variables
84+
// process.env.VISUAL_STORYBOOK_CLIP_SELECTOR = clipSelector
85+
// // --skipStories
86+
// const skipStoriesOption = this.#options?.skipStories
87+
// const skipStoriesArgv = getArgvValue('--skipStories', value => value)
88+
// const skipStories = skipStoriesOption ?? skipStoriesArgv ?? []
89+
// const parsedSkipStories = parseSkipStories(skipStories)
90+
91+
// // Create the test files
92+
// createTestFiles({
93+
// clip,
94+
// clipSelector,
95+
// directoryPath: tempDir,
96+
// folders: 'this.folders', // Need to get the logic from the Visual service to here
97+
// framework: this.#config.framework as string,
98+
// numShards,
99+
// skipStories: parsedSkipStories,
100+
// storiesJson,
101+
// storybookUrl,
102+
// })
103+
104+
// // Create the capabilities
105+
// createStorybookCapabilities(this.#config.capabilities as WebdriverIO.Capabilities[])
105106

106107
// You end with this
107108
await super.initialize()
Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,33 @@
1+
import { join } from 'node:path'
12
import { config as sharedConfig } from './wdio.shared.conf.ts'
23

3-
export const config: Omit<WebdriverIO.Config, 'capabilities'> = {
4+
export const config: Omit<WebdriverIO.Config, 'capabilities'> = {
45
...sharedConfig,
56
logLevel: 'silent',
6-
//
7-
// ====================
8-
// Runner Configuration
9-
// ====================
10-
runner: [
11-
'storybook',
7+
// ========
8+
// Services
9+
// ========
10+
services: [
11+
// ===================
12+
// Image compare setup
13+
// ===================
14+
[
15+
'visual',
16+
{
17+
baselineFolder: join(process.cwd(), './__snapshots__/'),
18+
// debug: true,
19+
// storybook: {
20+
// /**
21+
// * Demo storybook URLs with a lot of components
22+
// */
23+
// // url: 'https://www.bbc.co.uk/iplayer/storybook/',
24+
// // url: 'https://angular.carbondesignsystem.com/',
25+
// // url: 'https://govuk-react.github.io/govuk-react/',
26+
// // skipStories: ['example-button--secondary', 'example-button--small']
27+
// // skipStories: 'example-button--secondary,example-button--small'
28+
// // skipStories: '/.*button.*/gm'
29+
// }
30+
},
31+
]
1232
],
13-
// services: [['visual', {}]],
1433
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { config as sharedConfig } from './wdio.shared.conf.ts'
2+
3+
export const config: Omit<WebdriverIO.Config, 'capabilities'> = {
4+
...sharedConfig,
5+
logLevel: 'silent',
6+
//
7+
// ====================
8+
// Runner Configuration
9+
// ====================
10+
runner: [
11+
'storybook',
12+
],
13+
// services: [['visual', {}]],
14+
capabilities: [
15+
// {
16+
// browserName: 'chrome',
17+
// 'goog:chromeOptions': {
18+
// args: [
19+
// '--headless'
20+
// ],
21+
// },
22+
// 'wdio-ics:options': {
23+
// logName: 'local-chrome-latest',
24+
// },
25+
// }
26+
]
27+
}

0 commit comments

Comments
 (0)