Kaynağa Gözat

set moduleNameMapper

Yuki Takei 6 yıl önce
ebeveyn
işleme
da8c49468a
2 değiştirilmiş dosya ile 8 ekleme ve 5 silme
  1. 8 3
      config/jest.config.js
  2. 0 2
      src/test/bootstrap.js

+ 8 - 3
config/jest.config.js

@@ -12,9 +12,6 @@ module.exports = {
   // Automatically reset mock state between every test
   // Automatically reset mock state between every test
   resetMocks: true,
   resetMocks: true,
 
 
-  // A map from regular expressions to module names that allow to stub out resources with a single module
-  // moduleNameMapper: {},
-
   projects: [
   projects: [
     {
     {
       displayName: 'server',
       displayName: 'server',
@@ -22,6 +19,14 @@ module.exports = {
       rootDir: '.',
       rootDir: '.',
       setupFilesAfterEnv: ['<rootDir>/src/test/bootstrap.js'],
       setupFilesAfterEnv: ['<rootDir>/src/test/bootstrap.js'],
       testMatch: ['<rootDir>/src/test/**/*.test.js'],
       testMatch: ['<rootDir>/src/test/**/*.test.js'],
+      // A map from regular expressions to module names that allow to stub out resources with a single module
+      moduleNameMapper: {
+        '@root/(.+)': '<rootDir>/$1',
+        '@commons/(.+)': '<rootDir>/src/lib/$1',
+        '@server/(.+)': '<rootDir>/src/server/$1',
+        '@alias/logger/(.+)': '<rootDir>/src/lib/service/logger/$1',
+        debug: '<rootDir>/src/lib/service/logger/alias-for-debug',
+      },
     },
     },
     // {
     // {
     //   displayName: 'client',
     //   displayName: 'client',

+ 0 - 2
src/test/bootstrap.js

@@ -1,7 +1,5 @@
 process.env.NODE_ENV = 'test';
 process.env.NODE_ENV = 'test';
 
 
-require('module-alias/register');
-
 const express = require('express');
 const express = require('express');
 const path = require('path');
 const path = require('path');