Skip to content

Commit

Permalink
test: tsconfig paths (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber authored Jun 10, 2022
1 parent 59bc02b commit fe73074
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 28 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
"prepublishOnly": "npm test"
},
"dependencies": {
"@esbuild-kit/cjs-loader": "^2.0.1",
"@esbuild-kit/core-utils": "^1.2.1",
"@esbuild-kit/esm-loader": "^2.1.4"
"@esbuild-kit/cjs-loader": "^2.1.0",
"@esbuild-kit/core-utils": "^1.3.1",
"@esbuild-kit/esm-loader": "^2.2.0"
},
"optionalDependencies": {
"fsevents": "~2.3.2"
Expand Down Expand Up @@ -69,6 +69,7 @@
"error",
{
"allow": [
"test",
"describe",
"runTestSuite"
]
Expand Down
58 changes: 35 additions & 23 deletions pnpm-lock.yaml

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

3 changes: 3 additions & 0 deletions tests/fixtures/tsconfig/src/base-url.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import value from 'resolve-target';

console.log(value);
3 changes: 3 additions & 0 deletions tests/fixtures/tsconfig/src/paths-exact-match.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import value from 'paths-exact-match';

console.log(value);
3 changes: 3 additions & 0 deletions tests/fixtures/tsconfig/src/paths-prefix-match.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import value from 'p/nested-resolve-target';

console.log(value);
3 changes: 3 additions & 0 deletions tests/fixtures/tsconfig/src/paths-suffix-match.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import value from 'nested-resolve-target/s';

console.log(value);
1 change: 1 addition & 0 deletions tests/fixtures/tsconfig/src/resolve-target.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'resolved';
File renamed without changes.
1 change: 1 addition & 0 deletions tests/fixtures/tsconfig/src/utils/nested-resolve-target.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'resolved';
6 changes: 6 additions & 0 deletions tests/fixtures/tsconfig/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,11 @@
"jsx": "react",
"jsxFactory": "console.log",
"jsxFragmentFactory": "null",
"baseUrl": "./src",
"paths": {
"paths-exact-match": ["resolve-target"],
"p/*": ["utils/*"],
"*/s": ["utils/*"]
},
}
}
34 changes: 32 additions & 2 deletions tests/specs/typescript/tsconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,42 @@ import { testSuite, expect } from 'manten';
import type { NodeApis } from '../../utils/tsx';

export default testSuite(async ({ describe }, node: NodeApis) => {
describe('tsconfig', ({ test }) => {
describe('tsconfig', ({ test, describe }) => {
test('jsxFactory & jsxFragmentFactory', async () => {
const nodeProcess = await node.load('./tsx.tsx', {
const nodeProcess = await node.load('./src/tsx.tsx', {
cwd: './tsconfig',
});
expect(nodeProcess.stdout).toBe('div null hello world\nnull null goodbye world');
});

describe('paths', ({ test }) => {
test('resolves baseUrl', async () => {
const nodeProcess = await node.load('./src/base-url.ts', {
cwd: './tsconfig',
});
expect(nodeProcess.stdout).toBe('resolved');
});

test('resolves paths exact match', async () => {
const nodeProcess = await node.load('./src/paths-exact-match.ts', {
cwd: './tsconfig',
});
expect(nodeProcess.stdout).toBe('resolved');
});

test('resolves paths prefix', async () => {
const nodeProcess = await node.load('./src/paths-prefix-match.ts', {
cwd: './tsconfig',
});
expect(nodeProcess.stdout).toBe('resolved');
});

test('resolves paths suffix', async () => {
const nodeProcess = await node.load('./src/paths-suffix-match.ts', {
cwd: './tsconfig',
});
expect(nodeProcess.stdout).toBe('resolved');
});
});
});
});

0 comments on commit fe73074

Please sign in to comment.