Commit f8cb26c0 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig

test case

parent dc558fd4
import { loadSub, loadSubNested, loadSubFallback } from './src/foo' import {
load,
loadComplex,
loadSub,
loadSubNested,
loadSubFallback,
} from './src/foo'
it('should support dynamic requests with tsconfig.paths', () => { it('should support dynamic requests with tsconfig.paths', () => {
expect(loadSub('file2.js').default).toBe('file2') expect(load('sub/file2.js').default).toBe('file2')
expect(loadSub('file2.js').default).toBe('file2-override')
expect(loadComplex('sub', 'file2', 'js').default).toBe('file2')
}) })
it('should support dynamic requests with tsconfig.paths and without extension', () => { it('should support dynamic requests with tsconfig.paths and without extension', () => {
expect(loadSub('file2').default).toBe('file2') expect(loadSub('file2').default).toBe('file2-override')
}) })
it('should support dynamic requests with tsconfig.paths and multiple dynamic parts', () => { it('should support dynamic requests with tsconfig.paths and multiple dynamic parts', () => {
......
export function load(v: string) {
return require(`@/${v}`)
}
export function loadComplex(dir: string, name: string, ext: string) {
return require(`@/${dir}/${name}/${ext}`)
}
export function loadSub(v: string) { export function loadSub(v: string) {
return require(`@/sub/${v}`) return require(`@/sub/${v}`)
} }
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
"compilerOptions": { "compilerOptions": {
"paths": { "paths": {
"@/*": ["./*"], "@/*": ["./*"],
"@/sub/*": ["./sub-override/*"],
"@sub/*": ["./sub/*", "./sub-fallback/*"] "@sub/*": ["./sub/*", "./sub-fallback/*"]
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment