From 9c4ce68bbbd8ae06414b68f33ffcb9ddc27e75d8 Mon Sep 17 00:00:00 2001 From: Altrim Beqiri Date: Fri, 25 Sep 2020 10:14:37 +0200 Subject: [PATCH] test: ensure lodash-es replacement is done properly - lodash for CJS, lodash-es for ESM - previously, there were no tests for this behavior, so this adds them to ensure the replacement continues to work, even with the new fix with regex lookahead for `lodash/fp` Co-authored-by: Anton Gilgur --- test/e2e/tsdx-build-default.test.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/e2e/tsdx-build-default.test.ts b/test/e2e/tsdx-build-default.test.ts index ac90ad991..1f88d1ab1 100644 --- a/test/e2e/tsdx-build-default.test.ts +++ b/test/e2e/tsdx-build-default.test.ts @@ -67,6 +67,22 @@ describe('tsdx build :: zero-config defaults', () => { expect(matched).toBeFalsy(); }); + it('should use lodash for the CJS build', () => { + const output = execWithCache('node ../dist/index.js build'); + expect(output.code).toBe(0); + + const matched = grep(/lodash/, ['dist/build-default.cjs.*.js']); + expect(matched).toBeTruthy(); + }); + + it('should use lodash-es for the ESM build', () => { + const output = execWithCache('node ../dist/index.js build'); + expect(output.code).toBe(0); + + const matched = grep(/lodash-es/, ['dist/build-default.esm.js']); + expect(matched).toBeTruthy(); + }); + it("shouldn't replace lodash/fp", () => { const output = execWithCache('node ../dist/index.js build'); expect(output.code).toBe(0);