gilbsgilbs / babel-plugin-i18next-extract

Babel plugin that statically extracts i18next and react-i18next translation keys.

Home Page:https://i18next-extract.netlify.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

when running tests, I get a warning

chiptus opened this issue · comments

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

  • OS (e.g. ArchLinux): Ubuntu 20.04.1
  • Plugin version (e.g. 0.3.0): 0.8.3
  • Node version (e.g. 12.13.0): 16.13.2

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": []
}