пытаясь заставить шутку работать с описанием машинописного текста, он, afterAll, expect is undefined - PullRequest
0 голосов
/ 02 августа 2020

Попытка настроить jest с помощью машинописного текста, и мой линтер дает мне несколько красных волнистых строк с описанием, после Все говорят, что они не определены.

Я пробовал здесь несколько решений ReferenceError: description is not определены в Jest + Typescript , но они не работают.

мои версии

node: 12.16.3
"@types/jest": "^26.0.7"
"jest": "^26.1.0",
"ts-jest": "^26.1.4",
"typescript": "^3.9.7"

tsconfig. json:

{
  "compilerOptions": {
    "module": "commonjs",
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "target": "es6",
    "noImplicitAny": true,
    "moduleResolution": "node",
    "sourceMap": true
  },
  "include": [
    "node_modules/@types",
    "__test__/db/**/**.ts"
  ]
}

jest.config . js:

module.exports = {
  moduleFileExtensions: ['ts', 'js', 'jsx', 'tsx'],
  transform: {
    '^.+\\.(ts|tsx)$': 'ts-jest',
  },
  testMatch: ['**/__tests__/**/*.[jt]s?(x)'],
  testEnvironment: 'node'
};

и моя root tests папка выглядит так

__test__
  db
    tables
      users.test.ts 

и фрагмент моего тестового файла, которого должно хватить :

import { Pool } from 'pg';

describe('users table', (): void => {
  const conString: string = 'postgres://postgres:postgres@127.0.0.1:5432/testdb';

И просто вставьте мой .eslintr c. js:

module.exports = {
  extends: 'airbnb',
  parser: '@typescript-eslint/parser',
  env: {
    node: true,
    es6: true
  },
  rules: {
    'implicit-arrow-linebreak': 'off',
    'comma-dangle': 'off',
    indent: 'off',
    'no-trailing-spaces': 'off'
  },
  plugins: [
    '@typescript-eslint'
  ]
};

Есть идеи, где я отключился? Спасибо.

1 Ответ

0 голосов
/ 02 августа 2020

Добавление jest: true к объекту env внутри .eslintr c. js решено.

...