Skip to content

Commit

Permalink
Enable coverage properly
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperpeulen committed Aug 9, 2024
1 parent 04d4750 commit df27757
Show file tree
Hide file tree
Showing 10 changed files with 167 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
run: pnpm exec playwright install chromium --with-deps

- name: Run vitest
run: pnpm run test run --coverage
run: pnpm exec vitest run --coverage

- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
Expand Down
3 changes: 3 additions & 0 deletions .storybook-vite/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ initialize({ onUnhandledRequest: 'bypass', quiet: true })

const preview: Preview = {
parameters: {
react: {
rsc: true,
},
controls: {
matchers: {
color: /(background|color)$/i,
Expand Down
10 changes: 0 additions & 10 deletions .storybook-vite/storybook.setup.ts

This file was deleted.

3 changes: 0 additions & 3 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ const config: StorybookConfig = {
name: '@storybook/nextjs',
options: {},
},
features: {
experimentalRSC: true,
},
staticDirs: ['../public'],
}
export default config
3 changes: 3 additions & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ initialize({ onUnhandledRequest: 'bypass', quiet: true })

const preview: Preview = {
parameters: {
react: {
rsc: true,
},
controls: {
matchers: {
color: /(background|color)$/i,
Expand Down
5 changes: 1 addition & 4 deletions .storybook/vitest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { beforeAll } from 'vitest'
import { setProjectAnnotations } from '@storybook/nextjs'
import * as rscAnnotations from '@storybook/react/dist/entry-preview-rsc.mjs'
import * as projectAnnotations from './preview'
// promise with resolveres polyfill
import '@ungap/with-resolvers'

const annotations = setProjectAnnotations([projectAnnotations, rscAnnotations])
const annotations = setProjectAnnotations(projectAnnotations)

beforeAll(annotations.beforeAll!)
15 changes: 5 additions & 10 deletions app/note/[id]/page.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ type Story = StoryObj<typeof meta>
export const LoggedIn: Story = {
async beforeEach() {
cookies().set(userCookieKey, await createUserCookie('storybookjs'))

return () => {
cookies().delete(userCookieKey)
}
},
}

Expand All @@ -81,15 +77,14 @@ export const LoginShouldGetOAuthTokenAndSetCookie: Story = {
],
},
},
beforeEach() {
beforeEach() {},
play: async ({ mount }) => {
// Point the login implementation to the endpoint github would have redirected too.
login.mockImplementation(async () => {
const absoluteUrl = new URL('/auth?code=storybookjs', 'http://localhost').toString();
return await auth.GET(new Request(absoluteUrl))
const absoluteUrl = new URL('/auth?code=storybookjs', 'http://localhost')
return await auth.GET(new Request(absoluteUrl.toString()))
})
},
play: async ({ canvasElement }) => {
const canvas = within(canvasElement)
const canvas = await mount()
await expect(cookies().get(userCookieKey)?.value).toBeUndefined()
await userEvent.click(
await canvas.findByRole('menuitem', { name: /login to add/i }),
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"@types/sanitize-html": "^2.11.0",
"@ungap/with-resolvers": "^0.1.0",
"@vitest/browser": "^2.0.4",
"@vitest/coverage-istanbul": "^2.0.5",
"chromatic": "^11.3.0",
"concurrently": "^8.2.2",
"dotenv-cli": "^7.4.1",
Expand Down
Loading

0 comments on commit df27757

Please sign in to comment.