From a9be95de3d1c667530359994a366564f756785d1 Mon Sep 17 00:00:00 2001 From: Rob Brackett Date: Fri, 26 Jan 2024 00:56:54 +0000 Subject: [PATCH 1/3] Run TypeScript tests in ts-node We previously ran the `test/type-test.ts` test through the TypeScript compiler to catch type issues, but there are more subtle problems that can happen at runtime with tools like `ts-node` (and maybe things like Deno, too -- I haven't tested that). This additionally *runs* the test file to make sure it doesn't throw at runtime, which would have caught issues like #196 ahead of time. --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index fd002fa..266939d 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "test": "grunt test && npm run test-types", "test-browser": "grunt test-browser", "test-node": "grunt test-node", - "test-types": "tsc --noEmit ./test/type-test.ts", + "test-types": "tsc --noEmit ./test/type-test.ts && ts-node ./test/type-test.ts", "dist": "grunt dist", "dist-build": "grunt dist-build", "watch": "grunt watch" @@ -51,6 +51,7 @@ "grunt-open": "~0.2.3", "grunt-preprocess": "^5.1.0", "jasmine": "^2.4.1", + "ts-node": "^10.9.2", "typescript": "^3.5.1" }, "keywords": [ From 54f31ae8f31a6ef1eb6c5e9427322193f890a448 Mon Sep 17 00:00:00 2001 From: Rob Brackett Date: Fri, 26 Jan 2024 00:59:50 +0000 Subject: [PATCH 2/3] Deliberately cause tests to fail Test that the new test in ts-node is actually working. This needs to be reverted before shipping. --- lib/loglevel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/loglevel.js b/lib/loglevel.js index 307ab2f..b7b26ca 100644 --- a/lib/loglevel.js +++ b/lib/loglevel.js @@ -264,7 +264,7 @@ } // NOTE: in v2, this should call rebuild(), which updates children. - return replaceLoggingMethods.call(self); + return replaceLoggingMethods.call(this); }; self.setDefaultLevel = function (level) { From 54aadd463595026dddb14e924ef6bce49e6ccac7 Mon Sep 17 00:00:00 2001 From: Rob Brackett Date: Fri, 26 Jan 2024 01:05:46 +0000 Subject: [PATCH 3/3] Undo deliberate failure --- lib/loglevel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/loglevel.js b/lib/loglevel.js index b7b26ca..307ab2f 100644 --- a/lib/loglevel.js +++ b/lib/loglevel.js @@ -264,7 +264,7 @@ } // NOTE: in v2, this should call rebuild(), which updates children. - return replaceLoggingMethods.call(this); + return replaceLoggingMethods.call(self); }; self.setDefaultLevel = function (level) {