Ver código fonte

Update test configuration for `jest` dependency version 29+

Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
Mihaela Balutoiu 1 ano atrás
pai
commit
f0c0b3d217
3 arquivos alterados com 13 adições e 3 exclusões
  1. 1 1
      jest.config.ts
  2. 4 0
      jest.setup.js
  3. 8 2
      tests/fileTransform.js

+ 1 - 1
jest.config.ts

@@ -145,7 +145,7 @@ export default {
   setupFiles: ["<rootDir>/tests/setup.js"],
 
   // A list of paths to modules that run some code to configure or set up the testing framework before each test
-  // setupFilesAfterEnv: [],
+  setupFilesAfterEnv: ["<rootDir>/jest.setup.js"],
 
   // The number of seconds after which a test is considered as slow and reported as such in the results.
   // slowTestThreshold: 5,

+ 4 - 0
jest.setup.js

@@ -0,0 +1,4 @@
+import { TextEncoder, TextDecoder } from "util";
+
+global.TextEncoder = TextEncoder;
+global.TextDecoder = TextDecoder;

+ 8 - 2
tests/fileTransform.js

@@ -1,6 +1,12 @@
 const path = require("path");
 
 module.exports = {
-  process: (_, filename) =>
-    `module.exports = ${JSON.stringify(path.basename(filename))}`,
+  process(_, filename) {
+    return {
+      code: `module.exports = ${JSON.stringify(path.basename(filename))};`,
+    };
+  },
+  getCacheKey() {
+    return "fileTransform";
+  },
 };