gilbsgilbs / babel-plugin-i18next-extract

Babel plugin that statically extracts i18next and react-i18next translation keys.
https://i18next-extract.netlify.com
MIT License
161 stars 37 forks source link

when running tests, I get a warning #205

Open chiptus opened 2 years ago

chiptus commented 2 years ago

Describe the bug

when running tests using jest, I get the following warning:

babel-plugin-i18next-extract: Extraction error in $REPO/node_modules/jwt-decode/build/jwt-decode.cjs.js at line 1. Couldn't evaluate i18next key. You should either make the key evaluable or skip the line using a skip comment (/* i18next-extract-disable-line */ or /* i18next-extract-disable-next-line */).

test pass, but I would love to remove this warning.

How to reproduce

Babel configuration:

module.exports = {
  plugins: ['lodash', 'angularjs-annotate', ['i18next-extract', { outputPath: 'translations/{{locale}}/{{ns}}.json' }]],
  presets: [
    [
      '@babel/preset-env',
      {
        useBuiltIns: 'usage',
        corejs: '3',
        targets: { node: 'current' },
        modules: 'auto',
      },
    ],
  ],
  overrides: [
    {
      test: ['app/**/*.ts', 'app/**/*.tsx'],
      presets: [
        '@babel/preset-typescript',
        [
          '@babel/preset-react',
          {
            runtime: 'automatic',
          },
        ],
        [
          '@babel/preset-env',
          {
            modules: 'auto',
            useBuiltIns: 'usage',
            corejs: '3',
          },
        ],
      ],
    },
  ],
};

Your environment

Additional context jest config:

{
    "clearMocks": true,
    "coverageProvider": "v8",
    "globalSetup": "<rootDir>/app/setup-tests/global-setup.js",
    "moduleNameMapper": {
        "\\\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/app/__mocks__/fileMock.js",
        "\\\\.(css|less)$": "<rootDir>/app/__mocks__/styleMock.js",
        "^@/(.*)$": "<rootDir>/app/$1"
    },
    "roots": [
        "<rootDir>/app"
    ],
    "setupFilesAfterEnv": [
        "<rootDir>/app/setup-tests/setup-msw.ts"
    ],
    "testEnvironment": "jsdom",
    "transformIgnorePatterns": []
}