Skip to content

Commit

Permalink
Rename fixtures to integration tests (#1410)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrm007 authored Dec 5, 2023
1 parent 821b52a commit 8b7e348
Show file tree
Hide file tree
Showing 15 changed files with 33 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/preview-site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
preview:
name: Build & deploy
name: Build & Deploy
runs-on: ubuntu-latest
env:
CI: true
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,15 @@ jobs:
- name: Install Dependencies
run: pnpm i

- name: Build
run: pnpm build

- name: Lint
run: pnpm lint

- name: Test
- name: Build & Test
run: |
pnpm test
pnpm test:fixtures
# build must be run just before integration tests
pnpm build
pnpm test:integration
- name: Chromatic
run: pnpm storybook:chromatic
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion fixtures/jest.config.js → integration/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ const {
/** @type {import('jest').Config} */
module.exports = {
...rootJestConfig,
displayName: 'fixtures',
displayName: 'integration',
rootDir: __dirname,
};
7 changes: 4 additions & 3 deletions fixtures/consumer/package.json → integration/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "@braid-design-system/consumer",
"private": true,
"name": "@braid-design-system/integration-tests",
"version": "0.0.0",
"author": "SEEK",
"private": true,
"description": "deps needed for integration tests",
"license": "MIT",
"author": "SEEK",
"dependencies": {
"braid-design-system": "*"
},
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = {
],
testPathIgnorePatterns: [
`<rootDir>${slash}(.*${slash})?(dist|node_modules)${slash}`,
`<rootDir>/fixtures`, // these have a separate Jest config
`<rootDir>/integration`, // these have a separate Jest config
],
moduleFileExtensions: ['js', 'json', 'ts', 'tsx'],
moduleNameMapper: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "1.0.0",
"scripts": {
"test": "pnpm run generate && jest",
"test:fixtures": "pnpm run build && jest --config fixtures/jest.config.js",
"test:integration": "jest --config integration/jest.config.js",
"start": "nx run site:start",
"start:playroom": "nx run site:start:playroom",
"build": "nx run braid-design-system:build",
Expand Down
2 changes: 1 addition & 1 deletion packages/braid-design-system/codemod/bin.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env node
require('./dist/index');
require('./dist/index'); // eslint-disable-line import/no-unresolved
9 changes: 4 additions & 5 deletions packages/braid-design-system/scripts/generateIcons.cts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
import path from 'path';
import fs from 'fs-extra';
import glob from 'fast-glob';
Expand All @@ -10,7 +9,7 @@ import { optimize } from 'svgo';
// @ts-expect-error svgr@6 has types
import svgr from '@svgr/core';

import { relativeTo } from './utils';
import { debugLog, relativeTo } from './utils';

const baseDir = path.join(__dirname, '..');
const iconComponentsDir = path.join(baseDir, 'src/lib/components/icons');
Expand Down Expand Up @@ -139,10 +138,10 @@ const svgrConfig = {
const templateFileIfMissing = async (fileName: string, contents: string) => {
const filePath = path.join(iconDir, fileName);
if (await fs.pathExists(filePath)) {
console.log('Skip', relativeToProject(filePath));
debugLog('Skip', relativeToProject(filePath));
return;
}
console.log('Write', relativeToProject(filePath));
debugLog('Write', relativeToProject(filePath));
await fs.writeFile(filePath, `${contents}\n`, 'utf-8');
};

Expand Down Expand Up @@ -219,6 +218,6 @@ const svgrConfig = {
.join('\n')
.concat('\n');
const iconsIndexPath = path.join(iconComponentsDir, 'index.ts');
console.log('Update', relativeToProject(iconsIndexPath));
debugLog('Update', relativeToProject(iconsIndexPath));
await fs.writeFile(iconsIndexPath, iconExports, 'utf-8');
})();
5 changes: 2 additions & 3 deletions packages/braid-design-system/scripts/generateSnippets.cts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/* eslint-disable no-console */
import prettier from 'prettier';
import fs from 'fs-extra';
import glob from 'fast-glob';
import path from 'path';
import { transformFileAsync } from '@babel/core';

import { relativeTo } from './utils';
import { debugLog, relativeTo } from './utils';

const baseDir = path.join(__dirname, '..');
const componentsDir = path.join(baseDir, 'src/lib/components');
Expand Down Expand Up @@ -75,6 +74,6 @@ const transformWithBabel = async (fileName: string) => {
{ ...prettierOptions, parser: 'babel-ts' },
);

console.log('Update', relativeToProject(snippetsIndexFile));
debugLog('Update', relativeToProject(snippetsIndexFile));
await fs.writeFile(snippetsIndexFile, snippetsIndexCode, 'utf-8');
})();
10 changes: 10 additions & 0 deletions packages/braid-design-system/scripts/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
/* eslint-disable no-console */
import path from 'path';

/**
* Log to console if CI or DEBUG env vars are set
*/
export const debugLog = (...args: Parameters<typeof console.log>) => {
if (process.env.CI || process.env.DEBUG) {
console.log(...args);
}
};

/**
* Converts an absolute path to a relative path from the generated file
*/
Expand Down
4 changes: 2 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
packages:
- fixtures/*
- packages/*
- integration
- site
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
"braid-src/*": ["./packages/braid-design-system/src/*"]
}
},
"include": ["./fixtures", "./scripts"]
"include": ["./integration", "./scripts"]
}

0 comments on commit 8b7e348

Please sign in to comment.