Skip to content

Commit

Permalink
test(esbuild-meta): inline e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherPHolder committed May 27, 2024
1 parent e5e5fd5 commit 51a32d5
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 116 deletions.
18 changes: 0 additions & 18 deletions packages/esbuild-meta-e2e/.eslintrc.json

This file was deleted.

17 changes: 0 additions & 17 deletions packages/esbuild-meta-e2e/project.json

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions packages/esbuild-meta-e2e/tests/esbuild-meta.test.ts

This file was deleted.

22 changes: 0 additions & 22 deletions packages/esbuild-meta-e2e/tsconfig.json

This file was deleted.

24 changes: 0 additions & 24 deletions packages/esbuild-meta-e2e/tsconfig.spec.json

This file was deleted.

26 changes: 26 additions & 0 deletions packages/esbuild-meta/e2e/esbuild-meta.test.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { describe, it, expect, beforeAll } from 'vitest';
import { version } from '../package.json';

import { commandOutput } from './utils.js';

describe('--help', () => {
let helpOutput: string;

beforeAll(() => {
helpOutput = commandOutput('npx esbuild-meta --help');
});

it('should show help', () => {
expect(helpOutput).toMatchSnapshot();
});

it('should alias to -h', () => {
expect(commandOutput('npx esbuild-meta -h')).toBe(helpOutput);
});
});

describe('--version', () => {
it('should show version', () => {
expect(commandOutput('npx esbuild-meta --version')).toContain(version);
});
});
3 changes: 3 additions & 0 deletions packages/esbuild-meta/e2e/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { execSync } from 'child_process';

export const commandOutput = (command: string) => execSync(command).toString();
6 changes: 6 additions & 0 deletions packages/esbuild-meta/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
"reportsDirectory": "../../coverage/packages/esbuild-meta"
}
},
"e2e": {
"executor": "@nx/vite:test",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}-e2e"],
"options": { "config": "packages/esbuild-meta/vitest.config.e2e.ts" },
"dependsOn": ["^build"]
},
"version": {
"executor": "@jscutlery/semver:version",
"options": {
Expand Down
6 changes: 3 additions & 3 deletions packages/esbuild-meta/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import { argv } from 'node:process';
import { filterMetaCommand } from './lib/filter-meta.js';
import { version } from '../package.json'
import { version } from '../package.json';

yargs(hideBin(argv))
.scriptName('esbuild-meta')
.version(version)
.version(version).alias('v', 'version')
.showHelpOnFail(true)
.command(filterMetaCommand)
.help()
.alias('help', 'h')
.alias('h', 'help')
.wrap(null)
.parse();
2 changes: 2 additions & 0 deletions packages/esbuild-meta/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"include": [
"vite.config.ts",
"vitest.config.ts",
"vitest.config.e2e.ts",
"e2e/**/*.test.e2e.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.test.tsx",
Expand Down
2 changes: 1 addition & 1 deletion packages/esbuild-meta/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';

export default defineConfig({
root: __dirname,
cacheDir: '../../node_modules/.vite/packages/esbuild-meta',
cacheDir: '../../node_modules/.vite/packages/esbuild-meta/unit',

plugins: [nxViteTsPaths()],

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@ import { defineConfig } from 'vite';
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';

export default defineConfig({
cacheDir: '../../node_modules/.vite/esbuild-meta-e2e',
cacheDir: '../../node_modules/.vite/esbuild-meta/e2e',

plugins: [
nxViteTsPaths()
],
plugins: [nxViteTsPaths()],

test: {
watch: false,
reporters: ['default'],
globals: true,
cache: { dir: '../../node_modules/.vitest' },
environment: 'node',
include: ['tests/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
include: ['e2e/**/*.test.e2e.ts'],
globalSetup: '../../global-setup.e2e.ts'
},
});

0 comments on commit 51a32d5

Please sign in to comment.