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 = `http://localhost?redirect_uri=${encodeURIComponent(redirectUri)}&scope=${encodeURIComponent(OAUTH_SCOPE)}`;
29 process.env.VITE_OAUTH_REDIRECT_URI = redirectUri;
30 }
31 process.env.VITE_OAUTH_SCOPE = OAUTH_SCOPE;
32 }
33 }
34 ],
35 server: {
36 host: SERVER_HOST,
37 port: SERVER_PORT,
38 allowedHosts: ['localhost', 'bodhi-unremunerated-lily.ngrok-free.dev']
39 },
40 test: {
41 expect: {
42 requireAssertions: true
43 },
44 projects: [
45 {
46 extends: './vite.config.ts',
47 test: {
48 name: 'client',
49 browser: {
50 enabled: true,
51 provider: playwright(),
52 instances: [
53 {
54 browser: 'chromium',
55 headless: true
56 }
57 ]
58 },
59 include: ['src/**/*.svelte.{test,spec}.{js,ts}'],
60 exclude: ['src/lib/server/**']
61 }
62 },
63 {
64 extends: './vite.config.ts',
65 test: {
66 name: 'server',
67 environment: 'node',
68 include: ['src/**/*.{test,spec}.{js,ts}'],
69 exclude: ['src/**/*.svelte.{test,spec}.{js,ts}']
70 }
71 },
72 {
73 extends: true,
74 plugins: [
75 // The plugin will run tests for the stories defined in your Storybook config
76 // See options at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon#storybooktest
77 storybookTest({
78 configDir: path.join(dirname, '.storybook')
79 })
80 ],
81 test: {
82 name: 'storybook',
83 browser: {
84 enabled: true,
85 headless: true,
86 provider: playwright({}),
87 instances: [
88 {
89 browser: 'chromium'
90 }
91 ]
92 },
93 setupFiles: ['.storybook/vitest.setup.ts']
94 }
95 }
96 ]
97 }
98});