Skip to content

Commit 309c51c

Browse files
committed
test: tsconfig
1 parent 0067c0e commit 309c51c

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

test/unit/lib/configuration/read.test.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,50 @@ describe('test/unit/lib/configuration/read.test.js', () => {
117117
}
118118
});
119119

120+
it('should support tsconfig.paths', async () => {
121+
await fse.ensureDir('node_modules');
122+
const tsconfigPath = 'tsconfig.json';
123+
const servicePath = 'test.ts';
124+
125+
try {
126+
await fse.writeFile(
127+
tsconfigPath,
128+
JSON.stringify({
129+
compilerOptions: {
130+
paths: {
131+
'@/test': ['./test.ts'],
132+
},
133+
},
134+
include: ['**/*.ts'],
135+
})
136+
);
137+
138+
await fse.writeFile(servicePath, "export const service = 'test-ts';");
139+
140+
configurationPath = 'serverless.ts';
141+
const configuration = {
142+
service: 'test-ts',
143+
provider: { name: 'aws' },
144+
};
145+
146+
await fsp.writeFile(
147+
configurationPath,
148+
`import { service } from '@/test';
149+
150+
export default {
151+
service: service,
152+
provider: { name: 'aws' },
153+
}`
154+
);
155+
const result = await readConfiguration(configurationPath);
156+
expect(result).to.deep.equal(configuration);
157+
} finally {
158+
await fse.remove('node_modules');
159+
await fsp.unlink(tsconfigPath);
160+
await fsp.unlink(servicePath);
161+
}
162+
});
163+
120164
it('should support deferred configuration result', async () => {
121165
// JS configurations are required (so immune to modules caching).
122166
// In this tests we cannot use same JS configuration path twice for testing

0 commit comments

Comments
 (0)