Skip to content

Commit

Permalink
test: delete js test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Timeless0911 committed Jul 8, 2024
1 parent c568c90 commit b3bcf58
Show file tree
Hide file tree
Showing 21 changed files with 16 additions and 82 deletions.
12 changes: 6 additions & 6 deletions e2e/cases/alias/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`alias in ts 1`] = `
exports[`alias should work 1`] = `
"var __webpack_modules__ = ({});
/************************************************************************/
// The module cache
Expand Down Expand Up @@ -42,18 +42,18 @@ __webpack_require__.ruid = "[email protected]";
/************************************************************************/
var __webpack_exports__ = {};
;// CONCATENATED MODULE: ./e2e/cases/alias/ts/src/a.ts
;// CONCATENATED MODULE: ./e2e/cases/alias/src/a.ts
const a = 'hello world';
;// CONCATENATED MODULE: ./e2e/cases/alias/ts/src/index.ts
;// CONCATENATED MODULE: ./e2e/cases/alias/src/index.ts
console.info(a);
export { a };
"
`;

exports[`alias in ts 2`] = `
exports[`alias should work 2`] = `
"(() => { // webpackBootstrap
"use strict";
var __webpack_modules__ = ({});
Expand Down Expand Up @@ -97,10 +97,10 @@ __webpack_require__.ruid = "[email protected]";
/************************************************************************/
var __webpack_exports__ = {};
;// CONCATENATED MODULE: ./e2e/cases/alias/ts/src/a.ts
;// CONCATENATED MODULE: ./e2e/cases/alias/src/a.ts
const a = 'hello world';
;// CONCATENATED MODULE: ./e2e/cases/alias/ts/src/index.ts
;// CONCATENATED MODULE: ./e2e/cases/alias/src/index.ts
console.info(a);
Expand Down
17 changes: 2 additions & 15 deletions e2e/cases/alias/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
import { join } from 'node:path';
import { expect, test } from 'vitest';
import { buildAndGetResults } from '#shared';

test('alias in js', async () => {
delete process.env.NODE_ENV;

const fixturePath = join(__dirname, 'js');
const { entries } = await buildAndGetResults(fixturePath);

expect(entries.esm).toContain('hello world');
expect(entries.cjs).toContain('hello world');
});

test('alias in ts', async () => {
delete process.env.NODE_ENV;

const fixturePath = join(__dirname, 'ts');
test('alias should work', async () => {
const fixturePath = __dirname;
const { entries } = await buildAndGetResults(fixturePath);

expect(entries.esm).toContain('hello world');
Expand Down
15 changes: 0 additions & 15 deletions e2e/cases/alias/js/rslib.config.ts

This file was deleted.

1 change: 0 additions & 1 deletion e2e/cases/alias/js/src/a.js

This file was deleted.

3 changes: 0 additions & 3 deletions e2e/cases/alias/js/src/index.js

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 0 additions & 5 deletions e2e/cases/define/index.pw.test.ts

This file was deleted.

18 changes: 2 additions & 16 deletions e2e/cases/define/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
import { join } from 'node:path';
import { expect, test } from 'vitest';
import { buildAndGetResults } from '#shared';

test('define in js', async () => {
const fixturePath = join(__dirname, 'js');
const { entries } = await buildAndGetResults(fixturePath);

// TODO: remove js/ts dir in cases `define` and `alias`
// supersede with a complex js/ts combined case
expect(entries.esm).not.toContain('console.info(VERSION)');
expect(entries.esm).toContain('1.0.0');

expect(entries.cjs).not.toContain('console.info(VERSION)');
expect(entries.cjs).toContain('1.0.0');
});

test('define in ts', async () => {
const fixturePath = join(__dirname, 'ts');
test('define should work', async () => {
const fixturePath = __dirname;
const { entries } = await buildAndGetResults(fixturePath);

expect(entries.esm).not.toContain('console.info(VERSION)');
Expand Down
15 changes: 0 additions & 15 deletions e2e/cases/define/js/rslib.config.ts

This file was deleted.

1 change: 0 additions & 1 deletion e2e/cases/define/js/src/index.js

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions e2e/cases/externals/browser/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { expect, test } from 'vitest';
import { buildAndGetResults } from '#shared';

test('should fail when platform is not "node"', async () => {
delete process.env.NODE_ENV;

const fixturePath = join(__dirname);
const build = buildAndGetResults(fixturePath);
await expect(build).rejects.toThrowError('Rspack build failed!');
Expand Down
2 changes: 0 additions & 2 deletions e2e/cases/externals/node/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { expect, test } from 'vitest';
import { buildAndGetResults } from '#shared';

test('auto externalize Node.js built-in modules when platform is "node"', async () => {
delete process.env.NODE_ENV;

const fixturePath = join(__dirname);
const { entries } = await buildAndGetResults(fixturePath);

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"typescript": "^5.4.5",
"vitest": "^1.6.0"
},
"packageManager": "pnpm@9.1.4",
"packageManager": "pnpm@9.5.0",
"engines": {
"node": ">=18.0.0",
"pnpm": ">=9.0.0"
Expand Down
4 changes: 4 additions & 0 deletions setupVitestTests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
beforeEach(() => {
// since our NODE_ENV injection logic is via cli, we need to delete "test" NODE_ENV to avoid affecting the default build config
delete process.env.NODE_ENV;
});
1 change: 1 addition & 0 deletions vitest.workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default defineWorkspace([
test: {
...shared,
name: 'artifact',
setupFiles: ['./setupVitestTests.js'],
include: ['e2e/cases/**/*.test.ts'],
exclude: ['e2e/cases/**/*.pw.test.ts', '**/node_modules/**'],
},
Expand Down

0 comments on commit b3bcf58

Please sign in to comment.