diff --git a/test/tests/tsdx-build.test.js b/test/tests/tsdx-build.test.js index 805dfb8a1..5998d6816 100644 --- a/test/tests/tsdx-build.test.js +++ b/test/tests/tsdx-build.test.js @@ -43,23 +43,27 @@ describe('tsdx build', () => { '--entry src/subdir1/subdir1-2/index.ts', '--entry src/**/*.ts', '--format esm,cjs'].join(' ')); + const outputFiles = shell.ls('-R', 'dist/'); - function testEntryOutput (filename) { - expect(shell.test('-f', `dist/${filename}.js`)).toBeTruthy(); - expect( - shell.test('-f', `dist/${filename}.cjs.development.js`) - ).toBeTruthy(); - expect( - shell.test('-f', `dist/${filename}.cjs.production.min.js`) - ).toBeTruthy(); - expect(shell.test('-f', `dist/${filename}.esm.js`)).toBeTruthy(); - expect(shell.test('-f', `dist/${filename}.d.ts`)).toBeTruthy(); + function arrToDict (arr) { + return arr.reduce((dict, elem) => { + dict[elem] = true; + return dict; + }, {}); } - - testEntryOutput('index') - testEntryOutput('foo') - testEntryOutput('subdir1/subdir1-2/index') - testEntryOutput('subdir1/glob') + const outputDict = arrToDict(outputFiles); + + const entries = ['index', 'foo', 'subdir1/subdir1-2/index', 'subdir1/glob']; + const expected = entries.reduce((dict, entry) => { + dict[`${entry}.js`] = true; + dict[`${entry}.cjs.development.js`] = true; + dict[`${entry}.cjs.production.min.js`] = true; + dict[`${entry}.esm.js`] = true; + dict[`${entry}.d.ts`] = true; + return dict; + }, {}); + + expect(outputDict).toMatchObject(expected); expect(output.code).toBe(0); });