chore: add jest global variables (#42573)

This commit is contained in:
Huyen Nguyen
2021-06-20 14:14:42 +07:00
committed by GitHub
parent 42e8b2247e
commit 2c16234853
82 changed files with 8 additions and 114 deletions

View File

@ -3,7 +3,8 @@
"es6": true, "es6": true,
"browser": true, "browser": true,
"mocha": true, "mocha": true,
"node": true "node": true,
"jest": true
}, },
"parser": "babel-eslint", "parser": "babel-eslint",
"root": true, "root": true,

View File

@ -1,4 +1,3 @@
/* global expect */
import { ensureLowerCaseEmail } from './User-Identity'; import { ensureLowerCaseEmail } from './User-Identity';
test('returns lowercase email when one exists', () => { test('returns lowercase email when one exists', () => {

View File

@ -1,5 +1,3 @@
/* global it expect */
import { getFallbackFrontEndDate } from '../boot/certificate'; import { getFallbackFrontEndDate } from '../boot/certificate';
import { fullStackChallenges } from './fixtures'; import { fullStackChallenges } from './fixtures';

View File

@ -1,4 +1,3 @@
/* global describe xdescribe it expect jest */
import { first, find } from 'lodash'; import { first, find } from 'lodash';
import { import {

View File

@ -1,4 +1,3 @@
/* global jest*/
import { isEqual } from 'lodash'; import { isEqual } from 'lodash';
import { isEmail } from 'validator'; import { isEmail } from 'validator';

View File

@ -1,4 +1,3 @@
/* global describe it expect jest */
import { mockReq as mockRequest, mockRes } from '../boot_tests/challenge.test'; import { mockReq as mockRequest, mockRes } from '../boot_tests/challenge.test';
import jwt from 'jsonwebtoken'; import jwt from 'jsonwebtoken';

View File

@ -1,4 +1,3 @@
/* global describe expect it */
import moment from 'moment-timezone'; import moment from 'moment-timezone';
import { dayCount } from './date-utils'; import { dayCount } from './date-utils';

View File

@ -1,7 +1,4 @@
/* eslint-disable camelcase */ /* eslint-disable camelcase */
/* global describe it expect */
/* global jest*/
import axios from 'axios'; import axios from 'axios';
import keys from '../../../../config/secrets'; import keys from '../../../../config/secrets';
import { import {

View File

@ -1,4 +1,3 @@
/* global describe it expect */
import { import {
getAccessTokenFromRequest, getAccessTokenFromRequest,
errorTypes, errorTypes,

View File

@ -1,4 +1,3 @@
/* global describe beforeEach expect it jest */
import inMemoryCache from './in-memory-cache'; import inMemoryCache from './in-memory-cache';
describe('InMemoryCache', () => { describe('InMemoryCache', () => {

View File

@ -1,5 +1,3 @@
/* global describe expect it jest */
const jwt = require('jsonwebtoken'); const jwt = require('jsonwebtoken');
const { getReturnTo, normalizeParams } = require('./redirection'); const { getReturnTo, normalizeParams } = require('./redirection');

View File

@ -1,4 +1,3 @@
/* global describe it expect jest */
import moment from 'moment-timezone'; import moment from 'moment-timezone';
import { import {

View File

@ -1,4 +1,3 @@
/* global expect */
import { import {
availableLangs, availableLangs,
langDisplayNames, langDisplayNames,

View File

@ -1,6 +1,5 @@
/* eslint-disable react/prop-types */ /* eslint-disable react/prop-types */
/* eslint-disable react/display-name */ /* eslint-disable react/display-name */
/* global jest */
import React from 'react'; import React from 'react';
const reactI18next = jest.genMockFromModule('react-i18next'); const reactI18next = jest.genMockFromModule('react-i18next');

View File

@ -1,4 +1,3 @@
/* global describe it expect */
import { import {
wrapHandledError, wrapHandledError,
unwrapHandledError unwrapHandledError

View File

@ -1,4 +1,3 @@
/* global jest, expect */
import React from 'react'; import React from 'react';
import ShallowRenderer from 'react-test-renderer/shallow'; import ShallowRenderer from 'react-test-renderer/shallow';
import envData from '../../../config/env.json'; import envData from '../../../config/env.json';

View File

@ -1,4 +1,3 @@
/* global expect */
import React from 'react'; import React from 'react';
import renderer from 'react-test-renderer'; import renderer from 'react-test-renderer';

View File

@ -1,4 +1,3 @@
/* global expect jest */
import React from 'react'; import React from 'react';
import ShallowRenderer from 'react-test-renderer/shallow'; import ShallowRenderer from 'react-test-renderer/shallow';

View File

@ -1,4 +1,3 @@
/* global expect jest */
import React from 'react'; import React from 'react';
import renderer from 'react-test-renderer'; import renderer from 'react-test-renderer';
import { Provider } from 'react-redux'; import { Provider } from 'react-redux';

View File

@ -1,5 +1,3 @@
/* global expect jest */
import React from 'react'; import React from 'react';
import { useStaticQuery } from 'gatsby'; import { useStaticQuery } from 'gatsby';
import { render } from '@testing-library/react'; import { render } from '@testing-library/react';

View File

@ -1,5 +1,3 @@
/* global expect */
import createExternalRedirect from './createExternalRedirects'; import createExternalRedirect from './createExternalRedirects';
describe('createExternalRedirects', () => { describe('createExternalRedirects', () => {

View File

@ -1,5 +1,3 @@
/* global expect */
import createLanguageRedirect from './createLanguageRedirect'; import createLanguageRedirect from './createLanguageRedirect';
describe('createLanguageRedirect for clientLocale === english', () => { describe('createLanguageRedirect for clientLocale === english', () => {

View File

@ -1,5 +1,3 @@
/* global expect */
import React from 'react'; import React from 'react';
import { render } from '@testing-library/react'; import { render } from '@testing-library/react';

View File

@ -1,5 +1,3 @@
/* global expect */
import React from 'react'; import React from 'react';
import { render } from '@testing-library/react'; import { render } from '@testing-library/react';

View File

@ -1,5 +1,3 @@
/* global jest, expect */
import React from 'react'; import React from 'react';
import { render, fireEvent } from '@testing-library/react'; import { render, fireEvent } from '@testing-library/react';

View File

@ -1,4 +1,3 @@
/* global expect */
import React from 'react'; import React from 'react';
import renderer from 'react-test-renderer'; import renderer from 'react-test-renderer';

View File

@ -1,4 +1,3 @@
/* global expect */
import React from 'react'; import React from 'react';
import { render, cleanup } from '@testing-library/react'; import { render, cleanup } from '@testing-library/react';

View File

@ -1,4 +1,3 @@
/* global expect jest */
import React from 'react'; import React from 'react';
import ShallowRenderer from 'react-test-renderer/shallow'; import ShallowRenderer from 'react-test-renderer/shallow';

View File

@ -1,5 +1,3 @@
/* global expect jest */
import React from 'react'; import React from 'react';
import { render } from '@testing-library/react'; import { render } from '@testing-library/react';

View File

@ -1,5 +1,3 @@
/* global expect jest */
import React from 'react'; import React from 'react';
import { render } from '@testing-library/react'; import { render } from '@testing-library/react';

View File

@ -1,5 +1,3 @@
/* global expect */
import React from 'react'; import React from 'react';
import { render } from '@testing-library/react'; import { render } from '@testing-library/react';
import TimeLine from './TimeLine'; import TimeLine from './TimeLine';

View File

@ -1,4 +1,3 @@
/* global jest, expect */
import React from 'react'; import React from 'react';
import ShallowRenderer from 'react-test-renderer/shallow'; import ShallowRenderer from 'react-test-renderer/shallow';

View File

@ -1,5 +1,3 @@
/* global expect jest */
import React from 'react'; import React from 'react';
import { render } from '@testing-library/react'; import { render } from '@testing-library/react';
import { Provider } from 'react-redux'; import { Provider } from 'react-redux';

View File

@ -1,4 +1,3 @@
/* global expect jest */
import React from 'react'; import React from 'react';
import ShallowRenderer from 'react-test-renderer/shallow'; import ShallowRenderer from 'react-test-renderer/shallow';
import TestRenderer from 'react-test-renderer'; import TestRenderer from 'react-test-renderer';

View File

@ -1,4 +1,3 @@
/* global expect */
import toLearnPath from '../utils/to-learn-path'; import toLearnPath from '../utils/to-learn-path';
import { withPrefix } from 'gatsby'; import { withPrefix } from 'gatsby';

View File

@ -1,5 +1,3 @@
/* global expect jest */
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { ActionsObservable, StateObservable } from 'redux-observable'; import { ActionsObservable, StateObservable } from 'redux-observable';
import failedUpdatesEpic from './failed-updates-epic'; import failedUpdatesEpic from './failed-updates-epic';

View File

@ -1,5 +1,3 @@
/* global jest */
import { types } from '.'; import { types } from '.';
import { createGaSaga } from './ga-saga'; import { createGaSaga } from './ga-saga';
import ga from '../analytics'; import ga from '../analytics';

View File

@ -1,5 +1,3 @@
/* global expect */
import React from 'react'; import React from 'react';
import renderer from 'react-test-renderer'; import renderer from 'react-test-renderer';

View File

@ -1,5 +1,3 @@
/* global expect jest */
import { getCompletedPercent } from './CompletionModal'; import { getCompletedPercent } from './CompletionModal';
jest.mock('../../../analytics'); jest.mock('../../../analytics');

View File

@ -1,5 +1,3 @@
/* global jest, expect */
import React from 'react'; import React from 'react';
import { render, fireEvent } from '@testing-library/react'; import { render, fireEvent } from '@testing-library/react';

View File

@ -1,4 +1,3 @@
/* global expect */
import { findIndexHtml } from './builders.js'; import { findIndexHtml } from './builders.js';
const withHTML = [ const withHTML = [

View File

@ -1,5 +1,3 @@
/* global expect */
import { transformEditorLink } from '../utils'; import { transformEditorLink } from '../utils';
describe('create-question-epic', () => { describe('create-question-epic', () => {

View File

@ -1,5 +1,3 @@
/* global expect */
import envData from '../../../../../config/env.json'; import envData from '../../../../../config/env.json';
const { forumLocation } = envData; const { forumLocation } = envData;

View File

@ -1,5 +1,3 @@
/* global expect, jest */
import createWorker from './worker-executor'; import createWorker from './worker-executor';
function mockWorker({ init, postMessage, terminate } = {}) { function mockWorker({ init, postMessage, terminate } = {}) {

View File

@ -1,4 +1,3 @@
/* global describe it expect */
import { cssString } from './__fixtures/curriculum-helpers-css'; import { cssString } from './__fixtures/curriculum-helpers-css';
import CSSHelp from './css-help'; import CSSHelp from './css-help';

View File

@ -1,5 +1,3 @@
/* global describe it expect */
import __testHelpers, { removeJSComments } from './curriculum-helpers'; import __testHelpers, { removeJSComments } from './curriculum-helpers';
import jsTestValues from './__fixtures/curriculum-helpers-javascript'; import jsTestValues from './__fixtures/curriculum-helpers-javascript';
import cssTestValues from './__fixtures/curriculum-helpers-css'; import cssTestValues from './__fixtures/curriculum-helpers-css';

View File

@ -1,4 +1,4 @@
/* global expect BigInt */ /* global BigInt */
const { format } = require('./format'); const { format } = require('./format');

View File

@ -1,4 +1,3 @@
/* global expect jest */
import { isObject } from 'lodash-es'; import { isObject } from 'lodash-es';
import { import {
isHandledError, isHandledError,

View File

@ -1,4 +1,3 @@
/* global expect jest */
import React from 'react'; import React from 'react';
import { Provider } from 'react-redux'; import { Provider } from 'react-redux';
import ShallowRenderer from 'react-test-renderer/shallow'; import ShallowRenderer from 'react-test-renderer/shallow';

View File

@ -1,5 +1,3 @@
/* global expect */
import { injectConditionalTags } from './tags'; import { injectConditionalTags } from './tags';
describe('Tags', () => { describe('Tags', () => {

View File

@ -1,4 +1,3 @@
/* global expect */
// TODO: reinstate these tests // TODO: reinstate these tests
// // TODO: update these to use the new parser // // TODO: update these to use the new parser

View File

@ -1,4 +1,3 @@
/* global expect */
const path = require('path'); const path = require('path');
const { const {

View File

@ -1,4 +1,3 @@
/* global expect */
const extractCSSComments = require('./extract-css-comments'); const extractCSSComments = require('./extract-css-comments');
const someHTMLWithCSS = `<body> const someHTMLWithCSS = `<body>

View File

@ -1,4 +1,3 @@
/* global expect */
const extractHTMLComments = require('./extract-html-comments'); const extractHTMLComments = require('./extract-html-comments');
const someHTML = `<body> const someHTML = `<body>

View File

@ -1,4 +1,3 @@
/* global expect */
const extractJSComments = require('./extract-js-comments'); const extractJSComments = require('./extract-js-comments');
const someJS = ` const someJS = `

View File

@ -1,4 +1,3 @@
/* global expect */
const extractJSXComments = require('./extract-jsx-comments'); const extractJSXComments = require('./extract-jsx-comments');
const someJSX = `<Link const someJSX = `<Link

View File

@ -1,4 +1,3 @@
/* global expect */
const extractScriptJSComments = require('./extract-script-js-comments'); const extractScriptJSComments = require('./extract-script-js-comments');
const inlineComments = `<body> const inlineComments = `<body>

View File

@ -1,4 +1,3 @@
/* global expect */
const { sortChallenges } = require('./sort-challenges'); const { sortChallenges } = require('./sort-challenges');
const challenges = [ const challenges = [

View File

@ -1,4 +1,4 @@
/* global cy expect */ /* global cy */
const selectors = { const selectors = {
challengeMap: "[data-test-label='learn-curriculum-map']" challengeMap: "[data-test-label='learn-curriculum-map']"

View File

@ -1,4 +1,4 @@
/* global cy expect */ /* global cy */
const locations = { const locations = {
chalSuper: '/challenges/responsive-web-design/', chalSuper: '/challenges/responsive-web-design/',

View File

@ -1,4 +1,4 @@
/* global cy expect */ /* global cy */
import '@testing-library/cypress/add-commands'; import '@testing-library/cypress/add-commands';

View File

@ -1,4 +1,4 @@
/* global cy expect */ /* global cy */
describe('Settings', () => { describe('Settings', () => {
it('should be possible to reset your progress', () => { it('should be possible to reset your progress', () => {

View File

@ -1,4 +1,4 @@
/* global cy expect */ /* global cy */
describe('Report User', () => { describe('Report User', () => {
beforeEach(() => { beforeEach(() => {

View File

@ -1,5 +1,3 @@
/* global expect */
const path = require('path'); const path = require('path');
const { parseMD } = require('.'); const { parseMD } = require('.');

View File

@ -1,5 +1,3 @@
/* global describe it expect beforeEach */
const { isObject } = require('lodash'); const { isObject } = require('lodash');
const mockAST = require('../__fixtures__/ast-yaml-challenge.json'); const mockAST = require('../__fixtures__/ast-yaml-challenge.json');

View File

@ -1,4 +1,3 @@
/* global describe it expect beforeEach */
const isArray = require('lodash/isArray'); const isArray = require('lodash/isArray');
const simpleAST = require('../__fixtures__/ast-simple.json'); const simpleAST = require('../__fixtures__/ast-simple.json');

View File

@ -1,4 +1,3 @@
/* global describe it expect beforeEach */
const mockAST = require('../__fixtures__/ast-simple.json'); const mockAST = require('../__fixtures__/ast-simple.json');
const editableSolutionAST = require('../__fixtures__/ast-erm-in-solution.json'); const editableSolutionAST = require('../__fixtures__/ast-erm-in-solution.json');
const multiSolnsAST = require('../__fixtures__/ast-multiple-solutions.json'); const multiSolnsAST = require('../__fixtures__/ast-multiple-solutions.json');

View File

@ -1,4 +1,3 @@
/* global describe it expect beforeEach */
const simpleAST = require('../__fixtures__/ast-simple.json'); const simpleAST = require('../__fixtures__/ast-simple.json');
const brokenHintsAST = require('../__fixtures__/ast-broken-hints.json'); const brokenHintsAST = require('../__fixtures__/ast-broken-hints.json');
const addTests = require('./add-tests'); const addTests = require('./add-tests');

View File

@ -1,4 +1,3 @@
/* global describe it expect */
const mockAST = require('../__fixtures__/ast-simple.json'); const mockAST = require('../__fixtures__/ast-simple.json');
// eslint-disable-next-line max-len // eslint-disable-next-line max-len
const incorrectMarkersAST = require('../__fixtures__/ast-incorrect-markers.json'); const incorrectMarkersAST = require('../__fixtures__/ast-incorrect-markers.json');

View File

@ -1,4 +1,3 @@
/* global describe it expect beforeEach */
const simpleAST = require('../__fixtures__/ast-simple.json'); const simpleAST = require('../__fixtures__/ast-simple.json');
const mockVideoAST = require('../__fixtures__/ast-video-challenge.json'); const mockVideoAST = require('../__fixtures__/ast-video-challenge.json');
// eslint-disable-next-line max-len // eslint-disable-next-line max-len

View File

@ -1,4 +1,3 @@
/* global describe it expect jest */
const path = require('path'); const path = require('path');
const cloneDeep = require('lodash/cloneDeep'); const cloneDeep = require('lodash/cloneDeep');
const toVfile = require('to-vfile'); const toVfile = require('to-vfile');

View File

@ -1,4 +1,3 @@
/* global describe it expect */
const cloneDeep = require('lodash/cloneDeep'); const cloneDeep = require('lodash/cloneDeep');
const { selectAll } = require('unist-util-select'); const { selectAll } = require('unist-util-select');
const find = require('unist-util-find'); const find = require('unist-util-find');

View File

@ -1,4 +1,3 @@
/* global expect*/
const isArray = require('lodash/isArray'); const isArray = require('lodash/isArray');
const find = require('unist-util-find'); const find = require('unist-util-find');
const { root } = require('mdast-builder'); const { root } = require('mdast-builder');

View File

@ -1,4 +1,3 @@
/* global expect*/
const getId = require('./get-id'); const getId = require('./get-id');
const idNode = require('./__fixtures__/id-node.json'); const idNode = require('./__fixtures__/id-node.json');
const imageNode = require('./__fixtures__/image-node.json'); const imageNode = require('./__fixtures__/image-node.json');

View File

@ -1,4 +1,3 @@
/* global expect*/
const mdastToHTML = require('./mdast-to-html'); const mdastToHTML = require('./mdast-to-html');
const mdastMixedNodes = require('./__fixtures__/mdast-mixed-nodes.json'); const mdastMixedNodes = require('./__fixtures__/mdast-mixed-nodes.json');
const mdastWithEmNode = require('./__fixtures__/mdast-with-em.json'); const mdastWithEmNode = require('./__fixtures__/mdast-with-em.json');

View File

@ -1,4 +1,3 @@
/* global expect jest */
const { const {
translateComments, translateComments,
translateCommentsInChallenge, translateCommentsInChallenge,

View File

@ -1,4 +1,3 @@
/* global describe it expect jest beforeEach */
const path = require('path'); const path = require('path');
const lint = require('.'); const lint = require('.');

View File

@ -1,6 +1,3 @@
/* global expect */
/* global jest */
import React from 'react'; import React from 'react';
import { render, screen } from '@testing-library/react'; import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event'; import userEvent from '@testing-library/user-event';

View File

@ -1,5 +1,3 @@
/* global describe expect it */
const { getLines } = require('./get-lines'); const { getLines } = require('./get-lines');
const content = 'one\ntwo\nthree'; const content = 'one\ntwo\nthree';

View File

@ -1,5 +1,3 @@
/* global describe expect it */
const slugs = require('./slugs'); const slugs = require('./slugs');
describe('dasherize', () => { describe('dasherize', () => {

View File

@ -1,5 +1,3 @@
/* global expect */
const { toSortedArray } = require('./sort-files'); const { toSortedArray } = require('./sort-files');
const { challengeFiles } = require('./__fixtures__/challenges'); const { challengeFiles } = require('./__fixtures__/challenges');

View File

@ -1,5 +1,3 @@
/* global describe expect it */
const { const {
isValidUsername, isValidUsername,
usernameTooShort, usernameTooShort,