bluesky client without react native baggage written in sveltekit
1/// <reference types="vitest/config" />
2import devtoolsJson from 'vite-plugin-devtools-json';
3import tailwindcss from '@tailwindcss/vite';
4import { defineConfig } from 'vitest/config';
5import { playwright } from '@vitest/browser-playwright';
6import { sveltekit } from '@sveltejs/kit/vite';
7import path from 'node:path';
8import { fileURLToPath } from 'node:url';
9import { storybookTest } from '@storybook/addon-vitest/vitest-plugin';
10const dirname =
11 typeof __dirname !== 'undefined' ? __dirname : path.dirname(fileURLToPath(import.meta.url));
12
13const SERVER_HOST = '127.0.0.1';
14const SERVER_PORT = 12520;
15const OAUTH_SCOPE = 'atproto transition:generic';
16
17// More info at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon
18export default defineConfig({
19 plugins: [
20 tailwindcss(),
21 sveltekit(),
22 devtoolsJson(),
23 {
24 name: 'oauth-env',
25 config(_conf, { command }) {
26 const redirectUri = `http://${SERVER_HOST}:${SERVER_PORT}/oauth/callback`;
27 if (command === 'serve') {
28 process.env.VITE_OAUTH_CLIENT_ID =
29 `http://localhost?redirect_uri=${encodeURIComponent(redirectUri)}&scope=${encodeURIComponent(OAUTH_SCOPE)}`;
30 process.env.VITE_OAUTH_REDIRECT_URI = redirectUri;
31 }
32 process.env.VITE_OAUTH_SCOPE = OAUTH_SCOPE;
33 }
34 }
35 ],
36 server: {
37 host: SERVER_HOST,
38 port: SERVER_PORT,
39 allowedHosts: ['localhost', 'bodhi-unremunerated-lily.ngrok-free.dev']
40 },
41 test: {
42 expect: {
43 requireAssertions: true
44 },
45 projects: [
46 {
47 extends: './vite.config.ts',
48 test: {
49 name: 'client',
50 browser: {
51 enabled: true,
52 provider: playwright(),
53 instances: [
54 {
55 browser: 'chromium',
56 headless: true
57 }
58 ]
59 },
60 include: ['src/**/*.svelte.{test,spec}.{js,ts}'],
61 exclude: ['src/lib/server/**']
62 }
63 },
64 {
65 extends: './vite.config.ts',
66 test: {
67 name: 'server',
68 environment: 'node',
69 include: ['src/**/*.{test,spec}.{js,ts}'],
70 exclude: ['src/**/*.svelte.{test,spec}.{js,ts}']
71 }
72 },
73 {
74 extends: true,
75 plugins: [
76 // The plugin will run tests for the stories defined in your Storybook config
77 // See options at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon#storybooktest
78 storybookTest({
79 configDir: path.join(dirname, '.storybook')
80 })
81 ],
82 test: {
83 name: 'storybook',
84 browser: {
85 enabled: true,
86 headless: true,
87 provider: playwright({}),
88 instances: [
89 {
90 browser: 'chromium'
91 }
92 ]
93 },
94 setupFiles: ['.storybook/vitest.setup.ts']
95 }
96 }
97 ]
98 }
99});