chore: include react components in twenty-ui test config (#4709)
Split from https://github.com/twentyhq/twenty/pull/4518 Part of https://github.com/twentyhq/twenty/issues/4766 - Re-generates some of the twenty-ui test and storybook config with Nx - Includes tsx files in twenty-ui tests and compiles them with swc --------- Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
This commit is contained in:
31
nx.json
31
nx.json
@ -39,6 +39,24 @@
|
|||||||
"{workspaceRoot}/.eslintrc.js",
|
"{workspaceRoot}/.eslintrc.js",
|
||||||
"{workspaceRoot}/tools/eslint-rules/**/*"
|
"{workspaceRoot}/tools/eslint-rules/**/*"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"@nx/vite:test": {
|
||||||
|
"cache": true,
|
||||||
|
"inputs": ["default", "^default"]
|
||||||
|
},
|
||||||
|
"@nx/vite:build": {
|
||||||
|
"cache": true,
|
||||||
|
"dependsOn": ["^build"],
|
||||||
|
"inputs": ["default", "^default"]
|
||||||
|
},
|
||||||
|
"storybook:build": {
|
||||||
|
"cache": true,
|
||||||
|
"inputs": [
|
||||||
|
"default",
|
||||||
|
"^default",
|
||||||
|
"{projectRoot}/.storybook/**/*",
|
||||||
|
"{projectRoot}/tsconfig.storybook.json"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"installation": {
|
"installation": {
|
||||||
@ -54,21 +72,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"plugins": [
|
|
||||||
{
|
|
||||||
"plugin": "@nx/storybook/plugin",
|
|
||||||
"options": {
|
|
||||||
"buildStorybookTargetName": "build-storybook",
|
|
||||||
"serveStorybookTargetName": "storybook",
|
|
||||||
"testStorybookTargetName": "test-storybook",
|
|
||||||
"staticStorybookTargetName": "static-storybook"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"tasksRunnerOptions": {
|
"tasksRunnerOptions": {
|
||||||
"default": {
|
"default": {
|
||||||
"options": {
|
"options": {
|
||||||
"cacheableOperations": ["build-storybook"]
|
"cacheableOperations": ["storybook:build"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -3,17 +3,18 @@ import { StorybookConfig } from '@storybook/react-vite';
|
|||||||
const config: StorybookConfig = {
|
const config: StorybookConfig = {
|
||||||
stories: ['../src/**/*.stories.@(js|jsx|ts|tsx|mdx)'],
|
stories: ['../src/**/*.stories.@(js|jsx|ts|tsx|mdx)'],
|
||||||
addons: [
|
addons: [
|
||||||
|
'@storybook/addon-links',
|
||||||
'@storybook/addon-essentials',
|
'@storybook/addon-essentials',
|
||||||
|
'@storybook/addon-onboarding',
|
||||||
'@storybook/addon-interactions',
|
'@storybook/addon-interactions',
|
||||||
|
'@storybook/addon-coverage',
|
||||||
'@storybook/addon-themes',
|
'@storybook/addon-themes',
|
||||||
|
'storybook-addon-cookie',
|
||||||
|
'storybook-addon-pseudo-states',
|
||||||
],
|
],
|
||||||
framework: {
|
framework: {
|
||||||
name: '@storybook/react-vite',
|
name: '@storybook/react-vite',
|
||||||
options: {
|
options: {},
|
||||||
builder: {
|
|
||||||
viteConfigPath: 'vite.config.ts',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1,11 +1,23 @@
|
|||||||
/* eslint-disable */
|
import { JestConfigWithTsJest } from 'ts-jest';
|
||||||
export default {
|
|
||||||
|
const jestConfig: JestConfigWithTsJest = {
|
||||||
displayName: 'twenty-ui',
|
displayName: 'twenty-ui',
|
||||||
preset: '../../jest.preset.js',
|
preset: '../../jest.preset.js',
|
||||||
testEnvironment: 'node',
|
setupFilesAfterEnv: ['./setupTests.ts'],
|
||||||
|
transformIgnorePatterns: ['../../node_modules/'],
|
||||||
transform: {
|
transform: {
|
||||||
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
|
'^.+\\.[tj]sx?$': [
|
||||||
|
'@swc/jest',
|
||||||
|
{
|
||||||
|
jsc: {
|
||||||
|
parser: { syntax: 'typescript', tsx: true },
|
||||||
|
transform: { react: { runtime: 'automatic' } },
|
||||||
},
|
},
|
||||||
moduleFileExtensions: ['ts', 'js', 'html'],
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
|
||||||
coverageDirectory: '../../coverage/packages/twenty-ui',
|
coverageDirectory: '../../coverage/packages/twenty-ui',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default jestConfig;
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
],
|
],
|
||||||
"outputs": ["{projectRoot}/src/index.ts", "{projectRoot}/src/*/index.ts"],
|
"outputs": ["{projectRoot}/src/index.ts", "{projectRoot}/src/*/index.ts"],
|
||||||
"options": {
|
"options": {
|
||||||
|
"outputPath": "{projectRoot}/dist",
|
||||||
"command": "npx ts-node --esm {projectRoot}/scripts/generateBarrels.ts"
|
"command": "npx ts-node --esm {projectRoot}/scripts/generateBarrels.ts"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -37,9 +38,38 @@
|
|||||||
},
|
},
|
||||||
"test": {
|
"test": {
|
||||||
"executor": "@nx/jest:jest",
|
"executor": "@nx/jest:jest",
|
||||||
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
"outputs": ["{projectRoot}/coverage"],
|
||||||
"options": {
|
"options": {
|
||||||
"jestConfig": "packages/twenty-ui/jest.config.ts"
|
"jestConfig": "{projectRoot}/jest.config.ts"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"storybook:dev": {
|
||||||
|
"executor": "@nx/storybook:storybook",
|
||||||
|
"options": {
|
||||||
|
"port": 6007,
|
||||||
|
"configDir": "{projectRoot}/.storybook"
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"ci": { "quiet": true }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"storybook:build": {
|
||||||
|
"executor": "@nx/storybook:build",
|
||||||
|
"outputs": ["{options.outputDir}"],
|
||||||
|
"options": {
|
||||||
|
"outputDir": "{projectRoot}/storybook-static",
|
||||||
|
"configDir": "{projectRoot}/.storybook"
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"ci": {
|
||||||
|
"quiet": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"storybook:test": {
|
||||||
|
"executor": "nx:run-commands",
|
||||||
|
"options": {
|
||||||
|
"command": "test-storybook -c {projectRoot}/.storybook --url=http://localhost:6007"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
5
packages/twenty-ui/setupTests.ts
Normal file
5
packages/twenty-ui/setupTests.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
// jest-dom adds custom jest matchers for asserting on DOM nodes.
|
||||||
|
// allows you to do things like:
|
||||||
|
// expect(element).toHaveTextContent(/react/i)
|
||||||
|
// learn more: https://github.com/testing-library/jest-dom
|
||||||
|
import '@testing-library/jest-dom';
|
||||||
@ -1,20 +1,18 @@
|
|||||||
import { Meta, StoryObj } from '@storybook/react';
|
import { Meta, StoryObj } from '@storybook/react';
|
||||||
|
|
||||||
import { ComponentDecorator } from '../../testing/decorators/ComponentDecorator';
|
import { ComponentDecorator } from '../../../testing/decorators/ComponentDecorator';
|
||||||
|
import { Pill } from '../Pill';
|
||||||
import { Pill } from './Pill';
|
|
||||||
|
|
||||||
const meta: Meta<typeof Pill> = {
|
const meta: Meta<typeof Pill> = {
|
||||||
title: 'UI/Display/Pill/Pill',
|
title: 'UI/Display/Pill',
|
||||||
component: Pill,
|
component: Pill,
|
||||||
|
decorators: [ComponentDecorator],
|
||||||
|
args: {
|
||||||
|
label: 'Soon',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default meta;
|
export default meta;
|
||||||
type Story = StoryObj<typeof Pill>;
|
type Story = StoryObj<typeof Pill>;
|
||||||
|
|
||||||
export const Default: Story = {
|
export const Default: Story = {};
|
||||||
args: {
|
|
||||||
label: 'Soon',
|
|
||||||
},
|
|
||||||
decorators: [ComponentDecorator],
|
|
||||||
};
|
|
||||||
3
packages/twenty-ui/src/nx-react.d.ts
vendored
Normal file
3
packages/twenty-ui/src/nx-react.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
/// <reference types="@nx/react/typings/cssmodule.d.ts" />
|
||||||
|
/// <reference types="@nx/react/typings/image.d.ts" />
|
||||||
|
/// <reference types="@nx/react/typings/styled-jsx.d.ts" />
|
||||||
2
packages/twenty-ui/src/vite-env.d.ts
vendored
Normal file
2
packages/twenty-ui/src/vite-env.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/// <reference types="vite/client" />
|
||||||
|
/// <reference types="vite-plugin-svgr/client" />
|
||||||
@ -9,7 +9,7 @@
|
|||||||
"noPropertyAccessFromIndexSignature": true,
|
"noPropertyAccessFromIndexSignature": true,
|
||||||
"noImplicitReturns": true,
|
"noImplicitReturns": true,
|
||||||
"noFallthroughCasesInSwitch": true,
|
"noFallthroughCasesInSwitch": true,
|
||||||
"jsx": "react"
|
"jsx": "react-jsx"
|
||||||
},
|
},
|
||||||
"files": [],
|
"files": [],
|
||||||
"include": [],
|
"include": [],
|
||||||
|
|||||||
@ -9,7 +9,9 @@
|
|||||||
"jest.config.ts",
|
"jest.config.ts",
|
||||||
"src/**/*.d.ts",
|
"src/**/*.d.ts",
|
||||||
"src/**/*.spec.ts",
|
"src/**/*.spec.ts",
|
||||||
|
"src/**/*.spec.tsx",
|
||||||
"src/**/*.test.ts",
|
"src/**/*.test.ts",
|
||||||
|
"src/**/*.test.tsx",
|
||||||
"vite.config.ts"
|
"vite.config.ts"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
/// <reference types='vitest' />
|
/// <reference types='vitest' />
|
||||||
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
|
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
|
||||||
|
import react from '@vitejs/plugin-react-swc';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { defineConfig } from 'vite';
|
import { defineConfig } from 'vite';
|
||||||
import dts from 'vite-plugin-dts';
|
import dts from 'vite-plugin-dts';
|
||||||
@ -9,6 +10,7 @@ export default defineConfig({
|
|||||||
cacheDir: '../../node_modules/.vite/packages/twenty-ui',
|
cacheDir: '../../node_modules/.vite/packages/twenty-ui',
|
||||||
|
|
||||||
plugins: [
|
plugins: [
|
||||||
|
react(),
|
||||||
nxViteTsPaths(),
|
nxViteTsPaths(),
|
||||||
dts({
|
dts({
|
||||||
entryRoot: 'src',
|
entryRoot: 'src',
|
||||||
|
|||||||
Reference in New Issue
Block a user