File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
test/unit/lib/configuration Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,50 @@ describe('test/unit/lib/configuration/read.test.js', () => {
117
117
}
118
118
} ) ;
119
119
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
+
120
164
it ( 'should support deferred configuration result' , async ( ) => {
121
165
// JS configurations are required (so immune to modules caching).
122
166
// In this tests we cannot use same JS configuration path twice for testing
You can’t perform that action at this time.
0 commit comments