feat: configured storybook for the "ui" lib

feature/front-base-layout
Artem-Darius Weber 2 years ago
parent 526d79a3fd
commit b39f7a7e1e

@ -0,0 +1,10 @@
{
"extends": ["plugin:cypress/recommended", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
}
]
}

@ -0,0 +1,6 @@
import { defineConfig } from 'cypress';
import { nxE2EStorybookPreset } from '@nx/storybook/presets/cypress';
export default defineConfig({
e2e: nxE2EStorybookPreset(__dirname),
});

@ -0,0 +1,30 @@
{
"name": "ui-e2e",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/ui-e2e/src",
"projectType": "application",
"targets": {
"e2e": {
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "apps/ui-e2e/cypress.config.ts",
"devServerTarget": "ui:storybook",
"testingType": "e2e"
},
"configurations": {
"ci": {
"devServerTarget": "ui:static-storybook:ci"
}
}
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/ui-e2e/**/*.{js,ts}"]
}
}
},
"tags": [],
"implicitDependencies": ["ui"]
}

@ -0,0 +1,7 @@
describe('ui: Ui component', () => {
beforeEach(() => cy.visit('/iframe.html?id=ui--primary'));
it('should render the component', () => {
cy.get('h1').should('contain', 'Welcome to Ui!');
});
});

@ -0,0 +1,4 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io"
}

@ -0,0 +1,33 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
// eslint-disable-next-line @typescript-eslint/no-namespace
declare namespace Cypress {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Chainable<Subject> {
login(email: string, password: string): void;
}
}
//
// -- This is a parent command --
Cypress.Commands.add('login', (email, password) => {
console.log('Custom command example: Login', email, password);
});
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })

@ -0,0 +1,17 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// Import commands.js using ES2015 syntax:
import './commands';

@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"sourceMap": false,
"outDir": "../../dist/out-tsc",
"allowJs": true,
"types": ["cypress", "node"]
},
"include": ["src/**/*.ts", "src/**/*.js", "cypress.config.ts"]
}

@ -0,0 +1,18 @@
const config = {
stories: ['../src/lib/**/*.stories.@(js|jsx|ts|tsx|mdx)'],
addons: ['@storybook/addon-essentials'],
framework: {
name: '@storybook/react-vite',
options: {
builder: {
viteConfigPath: '',
},
},
},
};
export default config;
// To customize your Vite configuration you can use the viteFinal field.
// Check https://storybook.js.org/docs/react/builders/vite#configuration
// and https://nx.dev/packages/storybook/documents/custom-builder-configs

@ -0,0 +1,26 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"emitDecoratorMetadata": true,
"outDir": ""
},
"files": [
"../../../node_modules/@nx/react/typings/styled-jsx.d.ts",
"../../../node_modules/@nx/react/typings/cssmodule.d.ts",
"../../../node_modules/@nx/react/typings/image.d.ts"
],
"exclude": [
"../**/*.spec.ts",
"../**/*.spec.js",
"../**/*.spec.tsx",
"../**/*.spec.jsx"
],
"include": [
"../src/**/*.stories.ts",
"../src/**/*.stories.js",
"../src/**/*.stories.jsx",
"../src/**/*.stories.tsx",
"../src/**/*.stories.mdx",
"*.js"
]
}

@ -25,6 +25,43 @@
"codeCoverage": true
}
}
},
"storybook": {
"executor": "@nx/storybook:storybook",
"options": {
"port": 4400,
"configDir": "libs/ui/.storybook"
},
"configurations": {
"ci": {
"quiet": true
}
}
},
"build-storybook": {
"executor": "@nx/storybook:build",
"outputs": ["{options.outputDir}"],
"options": {
"outputDir": "dist/storybook/ui",
"configDir": "libs/ui/.storybook"
},
"configurations": {
"ci": {
"quiet": true
}
}
},
"static-storybook": {
"executor": "@nx/web:file-server",
"options": {
"buildTarget": "ui:build-storybook",
"staticFilePath": "dist/storybook/ui"
},
"configurations": {
"ci": {
"buildTarget": "ui:build-storybook:ci"
}
}
}
}
}

@ -0,0 +1,12 @@
import type { Meta } from '@storybook/react';
import { Ui } from './ui';
const Story: Meta<typeof Ui> = {
component: Ui,
title: 'Ui',
};
export default Story;
export const Primary = {
args: {},
};

@ -14,6 +14,9 @@
},
{
"path": "./tsconfig.spec.json"
},
{
"path": "./.storybook/tsconfig.json"
}
],
"extends": "../../tsconfig.base.json"

@ -17,7 +17,11 @@
"src/**/*.spec.js",
"src/**/*.test.js",
"src/**/*.spec.jsx",
"src/**/*.test.jsx"
"src/**/*.test.jsx",
"**/*.stories.ts",
"**/*.stories.js",
"**/*.stories.jsx",
"**/*.stories.tsx"
],
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
}

@ -4,7 +4,13 @@
"default": {
"runner": "nx-cloud",
"options": {
"cacheableOperations": ["build", "lint", "test", "e2e"],
"cacheableOperations": [
"build",
"lint",
"test",
"e2e",
"build-storybook"
],
"accessToken": "MjRlZTEyMmItZThlMS00MjBlLWI2MjctZDIxMzg2ZDJmOTkyfHJlYWQtd3JpdGU="
}
}
@ -26,6 +32,9 @@
},
"test": {
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"]
},
"build-storybook": {
"inputs": ["default", "^production", "!{projectRoot}/.storybook/**/*"]
}
},
"namedInputs": {
@ -35,7 +44,9 @@
"!{projectRoot}/.eslintrc.json",
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/jest.config.[jt]s"
"!{projectRoot}/jest.config.[jt]s",
"!{projectRoot}/**/*.stories.@(js|jsx|ts|tsx|mdx)",
"!{projectRoot}/.storybook/**/*"
],
"sharedGlobals": []
},

@ -32,14 +32,19 @@
"@nx/cypress": "16.4.0",
"@nx/eslint-plugin": "16.4.0",
"@nx/jest": "16.4.0",
"@nx/js": "16.4.0",
"@nx/js": "16.4.1",
"@nx/linter": "16.4.0",
"@nx/nest": "16.4.0",
"@nx/node": "16.4.0",
"@nx/react": "16.4.0",
"@nx/storybook": "16.4.1",
"@nx/web": "16.4.1",
"@nx/webpack": "16.4.0",
"@nx/workspace": "16.4.0",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.7",
"@storybook/addon-essentials": "^7.0.24",
"@storybook/core-server": "^7.0.24",
"@storybook/react-vite": "^7.0.24",
"@svgr/webpack": "^8.0.1",
"@swc/cli": "~0.1.62",
"@swc/core": "~1.3.51",
@ -72,6 +77,7 @@
"ts-jest": "^29.1.0",
"ts-node": "10.9.1",
"typescript": "~5.1.3",
"url-loader": "^4.1.1"
"url-loader": "^4.1.1",
"vite": "^4.3.4"
}
}

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save