Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SALTO-1155: Update jest version #1804

Merged
merged 5 commits into from
Jan 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ jobs:

- run: yarn config set cache-folder /mnt/ramdisk/yarn-cache

- run: yarn
# Yarn has some random race-condition failures, trying multiple times seems to help
# when the source of the problem is yarn itself and not the packages
- run: yarn || yarn || yarn
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will we always need this, or only until everything is upgraded?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is probably only relevant whenever we change any dependency (otherwise the first "yarn" would just do nothing an succeed, so the other two won't run)
I think we should leave it in though because I wouldn't want to re-discover this yarn bug every time we upgrade a package


- run:
# As a workaround to the --frozen-lockfile flag not working with workspaces
Expand Down
4 changes: 2 additions & 2 deletions jest.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ module.exports = {
collectCoverage: true,
coverageReporters: ['json', 'lcov', 'text', 'clover', 'json-summary'],
collectCoverageFrom: [
'**/*.js',
'**/*.jsx',
'**/dist/**/*.js',
'**/dist/**/*.jsx',
'!**/node_modules/**',
'!*.config.js',
'!coverage/**',
Expand Down
8 changes: 4 additions & 4 deletions packages/adapter-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"wu": "^2.1.0"
},
"devDependencies": {
"@types/jest": "^24.0.0",
"@types/jest": "^26.0.20",
"@types/lodash": "^4.14.133",
"@types/node": "^12.7.1",
"@types/shelljs": "^0.7.8",
Expand All @@ -52,9 +52,9 @@
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.14.3",
"eslint-plugin-react-hooks": "^1.7.0",
"jest": "^24.9.0",
"jest-circus": "^24.9.0",
"jest-junit": "^6.4.0",
"jest": "^26.6.3",
"jest-circus": "^26.6.3",
"jest-junit": "^12.0.0",
"tsc-watch": "^2.2.1",
"typescript": "3.9.3"
}
Expand Down
8 changes: 4 additions & 4 deletions packages/adapter-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"wu": "^2.1.0"
},
"devDependencies": {
"@types/jest": "^24.0.0",
"@types/jest": "^26.0.20",
"@types/lodash": "^4.14.133",
"@types/node": "^12.7.1",
"@types/shelljs": "^0.7.8",
Expand All @@ -55,9 +55,9 @@
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.14.3",
"eslint-plugin-react-hooks": "^1.7.0",
"jest": "^24.9.0",
"jest-circus": "^24.9.0",
"jest-junit": "^6.4.0",
"jest": "^26.6.3",
"jest-circus": "^26.6.3",
"jest-junit": "^12.0.0",
"tsc-watch": "^2.2.1",
"typescript": "3.9.3"
}
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"@types/express": "^4.17.7",
"@types/figlet": "^1.2.0",
"@types/inquirer": "0.0.35",
"@types/jest": "^24.0.0",
"@types/jest": "^26.0.20",
"@types/mkdirp": "^0.5.2",
"@types/rimraf": "^2.0.3",
"@types/semver": "^7.3.3",
Expand All @@ -83,8 +83,8 @@
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.14.3",
"eslint-plugin-react-hooks": "^1.7.0",
"jest": "^24.9.0",
"jest-junit": "^6.4.0",
"jest": "^26.6.3",
"jest-junit": "^12.0.0",
"memory-streams": "^0.1.3",
"nexe": "4.0.0-beta.6",
"sinon": "^9.0.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/test/commands/clean.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { action } from '../../src/commands/clean'
const commandName = 'clean'

jest.mock('@salto-io/core', () => ({
...jest.requireActual('@salto-io/core'),
...jest.requireActual<{}>('@salto-io/core'),
getDefaultAdapterConfig: jest.fn().mockImplementation(service => ({ a: 'a', serviceName: service })),
cleanWorkspace: jest.fn(),
}))
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/test/commands/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const mockDeploy = mocks.deploy
const mockPreview = mocks.preview
jest.mock('../../src/callbacks')
jest.mock('@salto-io/core', () => ({
...jest.requireActual('@salto-io/core'),
...jest.requireActual<{}>('@salto-io/core'),
deploy: jest.fn().mockImplementation((
ws: Workspace,
actionPlan: Plan,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/test/commands/diff.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import * as mocks from '../mocks'
const commandName = 'diff'

jest.mock('@salto-io/core', () => ({
...jest.requireActual('@salto-io/core'),
...jest.requireActual<{}>('@salto-io/core'),
diff: jest.fn().mockImplementation(() => Promise.resolve([])),
}))
describe('diff command', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/test/commands/element.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const mockedList: typeof core.listUnresolvedReferences = (_workspace, completeFr
)
jest.mock('open')
jest.mock('@salto-io/core', () => ({
...jest.requireActual('@salto-io/core'),
...jest.requireActual<{}>('@salto-io/core'),
listUnresolvedReferences: jest.fn().mockImplementation((_ws, env) => mockedList(_ws, env)),
}))
describe('Element command group', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/test/commands/fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const eventsNames = {
}

jest.mock('@salto-io/core', () => ({
...jest.requireActual('@salto-io/core'),
...jest.requireActual<{}>('@salto-io/core'),
fetch: jest.fn().mockImplementation(() => Promise.resolve({
changes: [],
mergeErrors: [],
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/test/commands/init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { getEnvName } from '../../src/callbacks'
import { CommandArgs } from '../../src/command_builder'

jest.mock('@salto-io/core', () => ({
...jest.requireActual('@salto-io/core'),
...jest.requireActual<{}>('@salto-io/core'),
initLocalWorkspace: jest.fn().mockImplementation(
(_baseDir: string, workspaceName: string): Workspace => {
if (workspaceName === 'error') throw new Error('failed')
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/test/commands/restore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const eventsNames = {
}

jest.mock('@salto-io/core', () => ({
...jest.requireActual('@salto-io/core'),
...jest.requireActual<{}>('@salto-io/core'),
restore: jest.fn().mockImplementation(() => Promise.resolve([])),
}))

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/test/commands/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jest.mock('../../src/cli_oauth_authenticator', () => ({
}),
}))
jest.mock('@salto-io/core', () => ({
...jest.requireActual('@salto-io/core'),
...jest.requireActual<{}>('@salto-io/core'),
getAdaptersCredentialsTypes: jest.fn().mockImplementation((serviceNames: string[]):
Record<string, AdapterAuthentication> => {
if (serviceNames[0] === 'noAdapter') {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/test/workspace/workspace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const mockWsFunctions = {

const mockWs = mockWsFunctions as unknown as Workspace
jest.mock('@salto-io/core', () => ({
...jest.requireActual('@salto-io/core'),
...jest.requireActual<{}>('@salto-io/core'),
loadLocalWorkspace: jest.fn().mockImplementation(() => mockWs),
}))
jest.mock('inquirer', () => ({
Expand Down
8 changes: 4 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"wu": "^2.1.0"
},
"devDependencies": {
"@types/jest": "^24.0.0",
"@types/jest": "^26.0.20",
"@types/lodash": "^4.14.133",
"@types/node": "^12.7.1",
"@types/supertest": "^2.0.4",
Expand All @@ -71,9 +71,9 @@
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.14.3",
"eslint-plugin-react-hooks": "^1.7.0",
"jest": "^24.9.0",
"jest-circus": "^24.9.0",
"jest-junit": "^6.4.0",
"jest": "^26.6.3",
"jest-circus": "^26.6.3",
"jest-junit": "^12.0.0",
"nock": "^12.0.1",
"tsc-watch": "^2.2.1",
"typescript": "3.9.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const mockServiceWithInstall = 'adapterWithInstallMethod'
const SERVICES = [mockService, emptyMockService]

jest.mock('../src/core/fetch', () => ({
...jest.requireActual('../src/core/fetch'),
...jest.requireActual<{}>('../src/core/fetch'),
fetchChanges: jest.fn(),
}))
jest.mock('../src/core/restore', () => ({
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/app_config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import * as conf from '../src/app_config'


jest.mock('@salto-io/file', () => ({
...jest.requireActual('@salto-io/file'),
...jest.requireActual<{}>('@salto-io/file'),
mkdirp: jest.fn(),
replaceContents: jest.fn(),
exists: jest.fn(),
Expand Down
4 changes: 2 additions & 2 deletions packages/core/test/core/adapters/adapters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import {
} from '../../../src/core/adapters'

jest.mock('@salto-io/workspace', () => ({
...jest.requireActual('@salto-io/workspace'),
...jest.requireActual<{}>('@salto-io/workspace'),
configSource: jest.fn(),
}))
jest.mock('@salto-io/adapter-utils', () => ({
...jest.requireActual('@salto-io/adapter-utils'),
...jest.requireActual<{}>('@salto-io/adapter-utils'),
createDefaultInstanceFromType: jest.fn(),
}))

Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/core/clean.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import * as adapters from '../../src/core/adapters'
import { mockWorkspace } from '../common/workspace'

jest.mock('../../src/core/adapters', () => ({
...jest.requireActual('../../src/core/adapters'),
...jest.requireActual<{}>('../../src/core/adapters'),
getDefaultAdapterConfig: jest.fn(service => ({ service, aaa: 'aaa' })),
}))

Expand Down
4 changes: 2 additions & 2 deletions packages/core/test/core/fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { mockFunction } from '../common/helpers'

jest.mock('pietile-eventemitter')
jest.mock('@salto-io/adapter-utils', () => ({
...jest.requireActual('@salto-io/adapter-utils'),
...jest.requireActual<{}>('@salto-io/adapter-utils'),
applyInstancesDefaults: jest.fn(),
}))

Expand Down Expand Up @@ -236,7 +236,7 @@ describe('fetch', () => {
}
})

describe('multiple adapters', async () => {
describe('multiple adapters', () => {
const adapters = {
dummy1: {
fetch: mockFunction<AdapterOperations['fetch']>().mockResolvedValue({ elements: [], isPartial: true }),
Expand Down
4 changes: 2 additions & 2 deletions packages/core/test/workspace/local/cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const { parseResultCache } = parseCache
type SourceMap = parser.SourceMap

jest.mock('@salto-io/file', () => ({
...jest.requireActual('@salto-io/file'),
...jest.requireActual<{}>('@salto-io/file'),
stat: jest.fn(),
exists: jest.fn(),
readFile: jest.fn(),
Expand All @@ -34,7 +34,7 @@ jest.mock('@salto-io/file', () => ({
}))

jest.mock('@salto-io/workspace', () => ({
...jest.requireActual('@salto-io/workspace'),
...jest.requireActual<{}>('@salto-io/workspace'),
serialize: jest.fn(),
}))

Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/workspace/local/directory_store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
import { localDirectoryStore } from '../../../src/local-workspace/dir_store'

jest.mock('@salto-io/file', () => ({
...jest.requireActual('@salto-io/file'),
...jest.requireActual<{}>('@salto-io/file'),
readdirp: jest.fn(),
stat: jest.fn(),
statSync: jest.fn(),
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/workspace/local/state.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jest.mock('glob', () => (query: string, f: (_err: Error | null, files: string[])
}
})
jest.mock('@salto-io/file', () => ({
...jest.requireActual('@salto-io/file'),
...jest.requireActual<{}>('@salto-io/file'),
replaceContents: jest.fn().mockImplementation(() => Promise.resolve()),
readTextFile: jest.fn().mockImplementation((filename: string) => {
if (filename === 'error') {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/test/workspace/local/workspace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ import * as mockDirStore from '../../../src/local-workspace/dir_store'
const { ENVS_PREFIX } = ws.nacl

jest.mock('@salto-io/file', () => ({
...jest.requireActual('@salto-io/file'),
...jest.requireActual<{}>('@salto-io/file'),
exists: jest.fn(),
rm: jest.fn(),
isEmptyDir: {
notFoundAsUndefined: jest.fn(() => true),
},
}))
jest.mock('@salto-io/workspace', () => ({
...jest.requireActual('@salto-io/workspace'),
...jest.requireActual<{}>('@salto-io/workspace'),
initWorkspace: jest.fn(),
loadWorkspace: jest.fn(),
}))
Expand Down
7 changes: 4 additions & 3 deletions packages/dag/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"wu": "^2.1.0"
},
"devDependencies": {
"@types/jest": "^26.0.20",
"eslint": "^6.2.2",
"eslint-config-airbnb": "18.0.1",
"eslint-plugin-header": "^3.0.0",
Expand All @@ -44,9 +45,9 @@
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.14.3",
"eslint-plugin-react-hooks": "^1.7.0",
"jest": "^24.9.0",
"jest-circus": "^24.9.0",
"jest-junit": "^6.4.0",
"jest": "^26.6.3",
"jest-circus": "^26.6.3",
"jest-junit": "^12.0.0",
"typescript": "3.9.3"
}
}
8 changes: 4 additions & 4 deletions packages/dummy-adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
"unique-names-generator": "^4.3.1"
},
"devDependencies": {
"@types/jest": "^24.0.0",
"@types/jest": "^26.0.20",
"@types/seedrandom": "^2.4.28",
"jest": "^24.9.0",
"jest-circus": "^24.9.0",
"jest-junit": "^6.4.0"
"jest": "^26.6.3",
"jest-circus": "^26.6.3",
"jest-junit": "^12.0.0"
}
}
14 changes: 11 additions & 3 deletions packages/e2e-credentials-store/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,18 @@ const deepMerge = require('../../build_utils/deep_merge')
module.exports = deepMerge(
require('../../eslintrc.js'),
{
overrides: [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just out of curiosity, why was this change needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because of the dynalite config file, because it is a .js file eslint wanted to lint it.
in the base eslint config we set a project for all files (that is probably a mistake, but I did not want to deal with that as part of this PR) but because this config .js file is not really a part of the project it made eslint fail.
This configuration override makes it so only .ts files will have the project attribute set.

btw - The project attribute is require only for lint rules that rely on types, I think we don't have any such rules enabled so it might be possible to get rid of this altogether, but again, didn't want to deal with that as part of this PR

{
files: ['*.ts'],
parserOptions: {
tsconfigRootDir: __dirname,
project: path.resolve(__dirname, './tsconfig.json'),
},
}
],
parserOptions: {
tsconfigRootDir: __dirname,
project: path.resolve(__dirname, './tsconfig.json'),
},
project: [],
}
},
)

18 changes: 18 additions & 0 deletions packages/e2e-credentials-store/jest-dynalite-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright 2021 Salto Labs Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module.exports = {
tables: [],
}