Skip to content

Commit a691149

Browse files
committed
Add dotenv exec in vitest config after rename of local .env to .env.development associated with e2e mock third-party service container work
1 parent 7eb40e3 commit a691149

3 files changed

Lines changed: 22 additions & 12 deletions

File tree

‎_TODO.md‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# TODO
22

3+
## Performance
4+
5+
Implement mitigations in test/e2e/specs/07-performance/PERFORMANCE.md
6+
37
## Analytics
48

59
Vercel Analytics
@@ -15,16 +19,9 @@ See note in src/components/scripts/sentry/client.ts - "User Feedback - allow use
1519

1620
## src/pages/api next steps
1721

18-
1. build Supabase-aware fixtures to cover the GDPR endpoints (consent/request/export/verify) end-to-end
19-
2. add integration-style tests that exercise the DSAR flow using a lightweight fake DB layer.
20-
3. Do the same for RESEND and the contact endpoint
21-
4. Where are we uploading files to? We need to implement the Uppy library in ContactForm, but currently nowhere to send the files to
22-
5. Need to add network failure testing modes to component unit tests where it's possible, but this is related to the above Toast issue.
23-
24-
Components that need full e2e testing implemented:
25-
26-
- CallToAction/Newsletter
27-
- ContactForm
22+
run npm run containers:up && npm run containers:wait
23+
start Supabase via npm run containers:supabase:start
24+
launch the dev server and Playwright against the mocks.
2825

2926
## Typing client-side API calls and SSR API endpoints
3027

‎src/components/Social/Shares/client/__tests__/index.spec.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { beforeEach, describe, expect, test, vi } from 'vitest'
1+
import { beforeAll, beforeEach, describe, expect, test, vi } from 'vitest'
22
import { experimental_AstroContainer as AstroContainer } from 'astro/container'
33
import { TestError } from '@test/errors'
4-
import SocialShareComponent from '@components/Social/Shares/index.astro'
54
import type { SocialShareElement } from '@components/Social/Shares/client/index'
65
import type { WebComponentModule } from '@components/scripts/@types/webComponentModule'
76
import { executeRender } from '@test/unit/helpers/litRuntime'
@@ -20,9 +19,16 @@ type ComponentProps = {
2019
socialNetworks?: ('twitter' | 'linkedin' | 'bluesky' | 'reddit' | 'mastodon')[]
2120
}
2221

22+
let SocialShareComponent: typeof import('@components/Social/Shares/index.astro').default
23+
2324
describe('SocialShareElement web component', () => {
2425
let container: AstroContainer
2526

27+
beforeAll(async () => {
28+
const module = await import('@components/Social/Shares/index.astro')
29+
SocialShareComponent = module.default
30+
})
31+
2632
beforeEach(async () => {
2733
container = await AstroContainer.create()
2834
})
@@ -37,6 +43,10 @@ describe('SocialShareElement web component', () => {
3743
props: ComponentProps = defaultProps,
3844
assertion: (_context: RenderContext) => Promise<void> | void,
3945
) => {
46+
if (!SocialShareComponent) {
47+
throw new TestError('SocialShareComponent failed to load')
48+
}
49+
4050
await executeRender<SocialShareModule>({
4151
container,
4252
component: SocialShareComponent,

‎vitest.config.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
/// <reference types="vitest" />
22
import { getViteConfig } from 'astro/config'
3+
import { config as loadEnv } from 'dotenv'
34
import { resolve } from 'path'
45
import { getSiteUrl } from './src/lib/config'
56

7+
loadEnv({ path: resolve(process.cwd(), '.env.development'), override: false })
8+
69
/**
710
* Needed to be able to skip running integrations in astro.config.ts
811
* during unit tests

0 commit comments

Comments
 (0)