Skip to content

Commit

Permalink
add webdriverio tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbf committed May 1, 2024
1 parent f807314 commit 1e379a1
Show file tree
Hide file tree
Showing 7 changed files with 1,542 additions and 115 deletions.
4 changes: 2 additions & 2 deletions .storybook/decorators.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import styled, { css, ThemeProvider } from 'styled-components'
import { Decorator } from '@storybook/react'
import { configureStore } from '@reduxjs/toolkit'
import { Provider as StoreProvider } from 'react-redux'
import { initialize, mswDecorator } from 'msw-storybook-addon'
import { initialize } from 'msw-storybook-addon'

import { rootReducer } from '../src/app-state'
import { breakpoints } from '../src/styles/breakpoints'
Expand Down Expand Up @@ -154,4 +154,4 @@ export const withRouter: Decorator = (StoryFn, { parameters: { deeplink } }) =>
}

// ordered from innermost to outermost, be careful with the order!
export const globalDecorators = [withRouter, withTheme, withStore, mswDecorator]
export const globalDecorators = [withRouter, withTheme, withStore]
2 changes: 2 additions & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { viewports as breakpoints } from '../src/styles/breakpoints'
import { DocsContainer, DocsContainerProps } from '@storybook/blocks'
import { ThemeProvider } from 'styled-components'
import { lightTheme } from '../src/styles/theme'
import { mswLoader } from 'msw-storybook-addon'

// Create custom viewports using widths defined in design tokens
const breakpointViewports = Object.keys(breakpoints).reduce((acc, key) => {
Expand Down Expand Up @@ -63,5 +64,6 @@ const preview: Preview = {
},
},
decorators: globalDecorators,
loaders: [mswLoader]
}
export default preview
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@
"vitest": "^1.5.2",
"vitest-axe": "^0.1.0",
"vitest-canvas-mock": "^0.3.3",
"wait-on": "^7.2.0"
"wait-on": "^7.2.0",
"webdriverio": "^8.36.1"
},
"resolutions": {
"@types/react": "^17.0.2",
Expand Down
6 changes: 4 additions & 2 deletions vitest.browser.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ import { mergeConfig } from 'vite'

import viteConfig from './vite.config'

const USE_WEBDRIVERIO = process.env.USE_WEBDRIVERIO === 'true'

// https://vitejs.dev/config/
export default mergeConfig(
viteConfig,
defineConfig({
test: {
browser: {
enabled: true,
name: 'chromium',
provider: 'playwright',
name: USE_WEBDRIVERIO ? 'chrome' : 'chromium',
provider: USE_WEBDRIVERIO ? 'webdriverio' : 'playwright',
},
globals: true,
clearMocks: true,
Expand Down
2 changes: 0 additions & 2 deletions vitest.node.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { mergeConfig } from 'vite'

import viteConfig from './vite.config'

console.log('opa')

// https://vitejs.dev/config/
export default mergeConfig(
viteConfig,
Expand Down
11 changes: 8 additions & 3 deletions vitest.workspace.config.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
import { defineWorkspace } from 'vitest/config'

const getBrowserConfig = (name: 'chromium' | 'firefox' | 'webkit') => ({
const USE_WEBDRIVERIO = process.env.USE_WEBDRIVERIO === 'true'

const getBrowserConfig = (name: string) => ({
extends: './vitest.browser.config.ts',
test: {
browser: {
enabled: true,
name,
provider: 'playwright',
provider: USE_WEBDRIVERIO ? 'webdriverio' : 'playwright',
},
globals: true,
clearMocks: true,
setupFiles: './src/setupTests.browser.ts',
},
})

const browsers = ['chromium', 'webkit', 'firefox'] as const
const browsers = USE_WEBDRIVERIO
? ['chrome', 'firefox', 'safari']
: ['chromium', 'firefox', 'webkit']

export default defineWorkspace(browsers.map(getBrowserConfig))
Loading

0 comments on commit 1e379a1

Please sign in to comment.