Skip to content

Commit

Permalink
TEST: Fix eslint & ban jest globals in non-test files
Browse files Browse the repository at this point in the history
  • Loading branch information
thoughtspile committed Dec 10, 2020
1 parent 7a0d1c0 commit e165330
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
22 changes: 15 additions & 7 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"extends": [
"@vkontakte/eslint-config/typescript/react",
"plugin:jest-playwright/recommended"
],
"extends": ["@vkontakte/eslint-config/typescript/react"],
"parserOptions": {
"project": "./tsconfig.json",
"ecmaVersion": 2018, // Allows for the parsing of modern ECMAScript features
Expand All @@ -19,8 +16,7 @@
"env": {
"es6": true, // Enable global es6 variables, like Set, Map, etc
"browser": true,
"node": true,
"jest": true
"node": true
},
"rules": {
"@typescript-eslint/explicit-member-accessibility": "off",
Expand All @@ -29,5 +25,17 @@
"@typescript-eslint/no-unused-vars": ["error", {
"ignoreRestSiblings": true
}]
}
},
"overrides": [
{
"files": ["src/**/*.{test,spec,e2e}.{ts,tsx}", "e2e/**/*", "src/testing/**/*"],
"env": {
"jest": true
}
},
{
"files": ["src/**/*.e2e.{ts,tsx}", "e2e/**/*", "src/testing/**/*"],
"extends": ["plugin:jest-playwright/recommended"]
}
]
}
8 changes: 4 additions & 4 deletions e2e/browser/mount.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ReactElement } from 'react'
import { currentPath } from './jest-mock'
import { testHandle } from './test-handle'
import { ReactElement } from 'react';
import { currentPath } from './jest-mock';
import { testHandle } from './test-handle';

export function mount(jsx: ReactElement) {
testHandle.register(currentPath(), jsx);
}

export const screenshot = mount;
export const screenshot = mount;
8 changes: 4 additions & 4 deletions e2e/jest.e2e.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const base = require('../jest.unit.config')
const base = require('../jest.unit.config');
const path = require('path');
const chalk = require('chalk');
const { canRunTests, useDocker } = require('./detectEnv');
Expand All @@ -10,7 +10,7 @@ const jestPlaywrightOptions = Object.assign({
width: 800,
height: 600,
},
}
},
}, useDocker ? {
connectOptions: {
wsEndpoint: 'ws://localhost:9001/playwright',
Expand All @@ -23,14 +23,14 @@ const config = {
preset: 'jest-playwright-preset',
collectCoverage: false,
setupFilesAfterEnv: [
...(base.setupFilesAfterEnv || []),
...base.setupFilesAfterEnv || [],
path.join(__dirname, 'jest/matchers.ts'),
],
globalSetup: path.join(__dirname, 'jest/globalSetup.ts'),
globalTeardown: path.join(__dirname, 'jest/globalTeardown.ts'),
testEnvironment: path.join(__dirname, 'jest/jsdomPlaywrightEnv.js'),
testEnvironmentOptions: {
...(base.testEnvironmentOptions || {}),
...base.testEnvironmentOptions || {},
'jest-playwright': jestPlaywrightOptions,
},
moduleNameMapper: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"test:e2e": "jest --config e2e/jest.e2e.config.js",
"test:code": "jest",

"lint:es": "eslint --ext .jsx,.js,.ts,.tsx src/ --cache --cache-location .cache/.eslintcache",
"lint:es": "eslint --ext .jsx,.js,.ts,.tsx src/ e2e/ --cache --cache-location .cache/.eslintcache",
"lint:es:ci": "yarn lint:es -o lint-results.json -f json",
"lint:style": "stylelint \"./src/**/*.css\" --cache --cache-location .cache/.stylelintcache",
"typecheck": "tsc --incremental --emitDeclarationOnly --declaration --tsBuildInfoFile .cache/.tsbuildinfo --outDir .cache/ts",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@react-playwright": ["../e2e"]
}
},
"include": ["src/**/*.ts", "src/**/*.tsx", "e2e/**/*.ts", "e2e/**/*.tsx"],
"include": ["src/**/*.ts", "src/**/*.tsx", "e2e/**/*.ts", "e2e/**/*.tsx", "e2e/**/*.js"],
"files": [
"node_modules/jest-playwright-preset/types/global.d.ts",
"node_modules/expect-playwright/global.d.ts"
Expand Down

0 comments on commit e165330

Please sign in to comment.