@shipfox/client-onboarding 22.0.3 → 24.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/vitest.config.ts CHANGED
@@ -1,7 +1,63 @@
1
+ import {readdirSync} from 'node:fs';
2
+ import * as path from 'node:path';
3
+ import {fileURLToPath} from 'node:url';
4
+ import {argosVitestPlugin} from '@argos-ci/storybook/vitest-plugin';
1
5
  import {defineConfig, type UserConfigExport} from '@shipfox/vitest';
6
+ import {storybookTest} from '@storybook/addon-vitest/vitest-plugin';
7
+ import tailwindcss from '@tailwindcss/vite';
8
+ import react from '@vitejs/plugin-react';
9
+ import {playwright} from '@vitest/browser-playwright';
10
+
11
+ const dirname =
12
+ typeof __dirname !== 'undefined' ? __dirname : path.dirname(fileURLToPath(import.meta.url));
13
+ const storybookFilePattern = /\.stories\.(?:[cm]?[jt]sx?|mdx)$/;
14
+
15
+ function hasStorybookStories(directory: string): boolean {
16
+ return readdirSync(directory, {withFileTypes: true}).some((entry) => {
17
+ const entryPath = path.join(directory, entry.name);
18
+ if (entry.isDirectory()) return hasStorybookStories(entryPath);
19
+ return entry.isFile() && storybookFilePattern.test(entry.name);
20
+ });
21
+ }
22
+
23
+ function createStorybookProject() {
24
+ return {
25
+ extends: true as const,
26
+ plugins: [
27
+ storybookTest({configDir: path.join(dirname, '.storybook')}),
28
+ argosVitestPlugin({
29
+ uploadToArgos: !!process.env.CI,
30
+ ...(process.env.ARGOS_TOKEN ? {token: process.env.ARGOS_TOKEN} : {}),
31
+ buildName: 'client-onboarding',
32
+ argosCSS: `
33
+ *, *::before, *::after {
34
+ animation-delay: 0s !important;
35
+ animation-duration: 0s !important;
36
+ transition-delay: 0s !important;
37
+ transition-duration: 0s !important;
38
+ }
39
+ `,
40
+ }),
41
+ ],
42
+ test: {
43
+ name: 'storybook',
44
+ browser: {
45
+ enabled: true,
46
+ headless: true,
47
+ provider: playwright({
48
+ launchOptions: {
49
+ args: ['--disable-lcd-text', '--font-render-hinting=none'],
50
+ },
51
+ }),
52
+ instances: [{browser: 'chromium' as const}],
53
+ },
54
+ },
55
+ };
56
+ }
2
57
 
3
58
  export default defineConfig(
4
59
  {
60
+ plugins: [react(), tailwindcss()],
5
61
  test: {
6
62
  projects: [
7
63
  {
@@ -24,6 +80,7 @@ export default defineConfig(
24
80
  setupFiles: ['test/setup.ts'],
25
81
  },
26
82
  },
83
+ ...(hasStorybookStories(path.join(dirname, 'src')) ? [createStorybookProject()] : []),
27
84
  ],
28
85
  },
29
86
  },