Skip to content

Commit

Permalink
Merge branch 'master' of github.com:seek-oss/sku into pnpm-9
Browse files Browse the repository at this point in the history
  • Loading branch information
askoufis committed May 8, 2024
2 parents bd92c6b + e532c39 commit b9f15b4
Show file tree
Hide file tree
Showing 8 changed files with 769 additions and 399 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Expand Up @@ -74,4 +74,4 @@ jobs:
key: jest-${{ runner.os }}-${{ hashFiles('./pnpm-lock.yaml') }}

- name: Test
run: pnpm run test --maxWorkers=2
run: pnpm run test
7 changes: 0 additions & 7 deletions .npmrc
Expand Up @@ -2,14 +2,7 @@
public-hoist-pattern[]="*eslint*"
public-hoist-pattern[]="*prettier*"

# `sku` itself needs these to be hoisted
public-hoist-pattern[]="babel-loader"
public-hoist-pattern[]="css-loader"

# This is only necessary in this repo because pnpm symlinks the sku dependency in fixtures to the sku package folder directly
# This bypasses the .pnpm folder that resolveModules looks for
# See https://github.com/seek-oss/sku/blob/275752bd3066e52885d461ef5bcd953aaac3bfff/config/webpack/resolveModules.js
public-hoist-pattern[]="@babel/*"

# Ensure that the same TypeScript version used by sku is used by the monorepo
public-hoist-pattern[]="typescript"
28 changes: 21 additions & 7 deletions tests/sku-init.test.js → fixtures/sku-init/sku-init.test.js
@@ -1,24 +1,38 @@
const path = require('node:path');
const fs = require('node:fs');
const { rimraf } = require('rimraf');
const fs = require('node:fs/promises');
const { promisify } = require('node:util');
const exec = promisify(require('node:child_process').exec);
const { runSkuScriptInDir } = require('@sku-private/test-utils');

const fixtureDirectory = path.join(__dirname, '../fixtures/sku-init');
const fixtureDirectory = __dirname;
const projectName = 'new-project';
const projectDirectory = path.join(fixtureDirectory, projectName);

describe('sku init', () => {
beforeAll(async () => {
await fs.rm(projectDirectory, { recursive: true, force: true });
});

afterAll(async () => {
await fs.rm(projectDirectory, { recursive: true, force: true });

console.log(
"Running 'pnpm install' to clean up lockfile after sku-init test...",
);
await exec('pnpm install');
console.log('Cleanup complete');
});

it(
'should create a sku.config.ts',
async () => {
const projectName = 'new-project';
await rimraf(path.join(fixtureDirectory, projectName));

const { child } = await runSkuScriptInDir('init', fixtureDirectory, [
projectName,
]);

expect(child.exitCode).toBe(0);

const skuConfig = fs.readFileSync(
const skuConfig = await fs.readFile(
path.join(fixtureDirectory, projectName, 'sku.config.ts'),
'utf-8',
);
Expand Down
1 change: 1 addition & 0 deletions fixtures/sku-webpack-plugin/package.json
Expand Up @@ -8,6 +8,7 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"babel-loader": "^9.1.2",
"mini-css-extract-plugin": "^2.6.1",
"html-webpack-plugin": "^5.3.2",
"sku": "workspace:*"
Expand Down
3 changes: 2 additions & 1 deletion jest.config.js
Expand Up @@ -3,6 +3,7 @@ module.exports = {
transform: {
'^.+\\.(t|j)sx?$': '@swc/jest',
},
maxWorkers: process.env.CI ? 2 : undefined,
preset: 'jest-puppeteer',
setupFilesAfterEnv: ['<rootDir>/test-utils/jestSetup.ts'],
snapshotSerializers: [
Expand All @@ -13,7 +14,7 @@ module.exports = {
testPathIgnorePatterns: [
'/node_modules/',
'<rootDir>/packages/sku/scripts/test.js',
'<rootDir>/fixtures/.*/src',
'<rootDir>/fixtures/.*',
],
watchPlugins: [
'jest-watch-typeahead/filename',
Expand Down
11 changes: 11 additions & 0 deletions jest.config.sku-init.js
@@ -0,0 +1,11 @@
const {
testPathIgnorePatterns: _testPathIgnorePatterns,
...baseJestConfig
} = require('./jest.config');

/** @type {import('jest').Config} */
module.exports = {
...baseJestConfig,
// Ensure that the only test that can be run with this config is sku-init.test.js
testRegex: 'sku-init\\.test\\.js$',
};
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -10,7 +10,9 @@
"lint:prettier": "prettier --cache --list-different '**/*.{js,ts,tsx,md,less,css}'",
"lint:tsc": "tsc",
"check": "pnpm install --frozen-lockfile && echo 'Ignore paths from lint-staged'",
"test": "SKU_TELEMETRY=false SKU_DISABLE_CACHE=true OPEN_TAB=false jest --verbose",
"test": "pnpm run test:rest && pnpm run test:sku-init",
"test:rest": "SKU_TELEMETRY=false SKU_DISABLE_CACHE=true OPEN_TAB=false jest --verbose",
"test:sku-init": "SKU_TELEMETRY=false SKU_DISABLE_CACHE=true OPEN_TAB=false jest --verbose --config=jest.config.sku-init.js",
"setup-test-hosts": "node test-utils/setupTestHosts",
"format": "prettier --cache --write '**/*.{js,ts,tsx,md,less,css}' && eslint --cache --fix .",
"deploy-docs": "pnpm run --filter @sku-private/docs deploy",
Expand Down

0 comments on commit b9f15b4

Please sign in to comment.