Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

[jest-config-terra] Jest 29 upgrade #863

Merged
merged 8 commits into from
May 6, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,871 changes: 2,260 additions & 1,611 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"enzyme-adapter-react-16": "1",
"eslint": "7",
"html-webpack-plugin": "4",
"jest": "27",
"jest": "29",
"lerna": "6",
"postcss": "8",
"stylelint": "15",
Expand All @@ -79,7 +79,7 @@
"danger": "danger ci",
"heroku-postbuild": "npm install --only=dev && npm run compile:prod",
"heroku-prebuild": "npx lerna init",
"jest": "jest",
"jest": "jest --no-coverage",
"lint:js": "eslint --ext .js,.jsx . --max-warnings 0",
"lint:js:fix": "eslint --fix --ext .js,.jsx .",
"lint:package-json": "npm run terra -- package-json-lint",
Expand Down
8 changes: 8 additions & 0 deletions packages/jest-config-terra/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@

## Unreleased

* Breaking Changes
* Updated to use Jest 29.
* Dropped support for Node 10 and 12 as Jest 29 requires Node 14 at minimum.

---

## 2.0.0 - (September 26, 2023)

* Breaking changes
* Updated to use Jest 27.
* Dropped support for Jest 26.

---

## 1.7.0 - (August 31, 2023)

* Changed
Expand Down
22 changes: 14 additions & 8 deletions packages/jest-config-terra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,34 @@
"access": "public"
},
"engines": {
"node": "^10.13.0 || 12 || 14",
"node": "14",
"npm": "6 || 9"
},
"main": "jest.config.js",
"files": [
"jest.config.js",
"lib",
"CHANGELOG.md",
"NOTICE",
"LICENSE"
],
"dependencies": {
"@cerner/terra-cli": "^1.12.0",
"@jest/reporters": "27",
"babel-jest": "27",
"babel-jest": "29",
"identity-obj-proxy": "^3.0.0",
"jest-environment-jsdom": "27",
"jest-jasmine2": "27",
"jest-mock": "27",
"jest-environment-jsdom": "29",
"jest-jasmine2": "29",
"jest-mock": "29",
"strip-ansi": "^6.0.0"
},
"peerDependencies": {
"jest": "27"
"jest": "29"
},
"devDependencies": {
"@babel/cli": "^7.10.5",
"@babel/core": "^7.11.1",
"@cerner/eslint-config-terra": "^5.6.0",
"eslint": "^7.32.0"
"@cerner/eslint-config-terra": "^5.6.0"
},
"scripts": {
"clean": "npm run clean:node_modules && npm run clean:lib",
Expand Down
5 changes: 3 additions & 2 deletions packages/jest-config-terra/src/JestEnvironmentJsdomTerra.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const JsdomEnvironment = require('jest-environment-jsdom');
const { TestEnvironment } = require('jest-environment-jsdom');
const JestMock = require('jest-mock');

/**
* The TerraJsdomEnvironment extends the JsdomEnvironment to mock a couple of extra functions and set the dir attribute.
*/
class TerraJsdomEnvironment extends JsdomEnvironment {

class TerraJsdomEnvironment extends TestEnvironment {
constructor(config, context) {
super(config, context);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
const JestEnvironmentJsdomTerra = require('../../src/JestEnvironmentJsdomTerra');

describe('jest environment jsdom terra', () => {
it('sets up the environment appropriately', () => {
const testConfig = {
globals: {},
testEnvironmentOptions: {},
};
expect(window.matchMedia()).toEqual({ matches: true });
expect(window.HTMLElement.prototype.scrollIntoView).toBeDefined();

const environment = new JestEnvironmentJsdomTerra(testConfig, {});
expect(environment.dom.window.matchMedia).toBeDefined();
expect(environment.dom.window.HTMLElement.prototype.scrollIntoView).toBeDefined();
const htmlTag = environment.dom.window.document.getElementsByTagName('html')[0];
const htmlTag = window.document.getElementsByTagName('html')[0];
expect(htmlTag.getAttribute('dir')).toEqual('ltr');
});
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`config getConfigForFile returns an extended config with 3 transitive extends 1`] = `
Object {
"rules": Object {
{
"rules": {
"a": 1,
"b": 2,
"c": 3,
Expand All @@ -12,8 +12,8 @@ Object {
`;

exports[`config getConfigForFile returns an extended config with multiple extenions 1`] = `
Object {
"rules": Object {
{
"rules": {
"a": 1,
"b": 2,
"c": 3,
Expand All @@ -26,8 +26,8 @@ Object {
`;

exports[`config getConfigForFile returns an extended config with multiple extenions and no override 1`] = `
Object {
"rules": Object {
{
"rules": {
"a": 1,
"b": 2,
"c": 3,
Expand All @@ -40,8 +40,8 @@ Object {
`;

exports[`config getConfigForFile returns an extended config with no transitive extend 1`] = `
Object {
"rules": Object {
{
"rules": {
"a": 1,
"b": 2,
"c": 3,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`getPathsForPackages returns a list of paths for packages that are not ignored for a monorepo 1`] = `
Array [
[
"/Users/x/ecosystem/terra-toolkit/package.json",
"/Users/x/ecosystem/terra-toolkit/packages/browserslist-config-terra/package.json",
"/Users/x/ecosystem/terra-toolkit/packages/duplicate-package-checker-webpack-plugin/package.json",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`require-dependencies-declared-at-appropriate-level when projectType is application fails as a warning when there unnecessary dependencies/peerDependencies 1`] = `
Array [
Object {
[
{
"lintId": "require-dependencies-declared-at-appropriate-level",
"lintMessage": "This project has unnecessary dependencies that violates the require-dependencies-declared-at-appropriate-level rule:
@cerner/webpack-config-terra@^2.0.0 does not satisfy requirement for require-dependencies-declared-at-appropriate-level rule.",
"projectType": "application",
"severity": Object {
"severity": {
"severityType": "warn",
},
},
Object {
{
"lintId": "require-dependencies-declared-at-appropriate-level",
"lintMessage": "This project has unnecessary peerDependencies that violates the require-dependencies-declared-at-appropriate-level rule:
jest@^26.6.2 does not satisfy requirement for require-dependencies-declared-at-appropriate-level rule.",
"projectType": "application",
"severity": Object {
"severity": {
"severityType": "warn",
},
},
]
`;

exports[`require-dependencies-declared-at-appropriate-level when projectType is application succeeds when there are no unnecessary dependencies/peerDependencies 1`] = `Array []`;
exports[`require-dependencies-declared-at-appropriate-level when projectType is application succeeds when there are no unnecessary dependencies/peerDependencies 1`] = `[]`;

exports[`require-dependencies-declared-at-appropriate-level when projectType is application succeeds when unnecessary dependencies/peerDependencies are passed in the allowList 1`] = `Array []`;
exports[`require-dependencies-declared-at-appropriate-level when projectType is application succeeds when unnecessary dependencies/peerDependencies are passed in the allowList 1`] = `[]`;

exports[`require-dependencies-declared-at-appropriate-level when projectType is devModule succeeds when there no unnecessary dependencies/peerDependencies 1`] = `Array []`;
exports[`require-dependencies-declared-at-appropriate-level when projectType is devModule succeeds when there no unnecessary dependencies/peerDependencies 1`] = `[]`;

exports[`require-dependencies-declared-at-appropriate-level when projectType is devModule succeeds when there unnecessary dependencies/peerDependencies 1`] = `Array []`;
exports[`require-dependencies-declared-at-appropriate-level when projectType is devModule succeeds when there unnecessary dependencies/peerDependencies 1`] = `[]`;

exports[`require-dependencies-declared-at-appropriate-level when projectType is module fails as a warning when there unnecessary dependencies/peerDependencies 1`] = `
Array [
Object {
[
{
"lintId": "require-dependencies-declared-at-appropriate-level",
"lintMessage": "This project has unnecessary peerDependencies that violates the require-dependencies-declared-at-appropriate-level rule:
jest@^26.6.2 does not satisfy requirement for require-dependencies-declared-at-appropriate-level rule.",
"projectType": "module",
"severity": Object {
"severity": {
"severityType": "warn",
},
},
]
`;

exports[`require-dependencies-declared-at-appropriate-level when projectType is module succeeds when there are no unnecessary dependencies/peerDependencies 1`] = `Array []`;
exports[`require-dependencies-declared-at-appropriate-level when projectType is module succeeds when there are no unnecessary dependencies/peerDependencies 1`] = `[]`;
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ exports[`require-no-hard-coded-dependency-versions when projectType is applicati
exports[`require-no-hard-coded-dependency-versions when projectType is application succeeds when there are no hardcoded dependencies 1`] = `undefined`;

exports[`require-no-hard-coded-dependency-versions when projectType is devModule fails when there are hardcoded dependencies 1`] = `
Object {
{
"lintId": "require-no-hard-coded-dependency-versions",
"lintMessage": "The dependencies for this project have hard-coded versions that violates the require-no-hard-coded-dependency-versions rule:
[email protected] does not satisfy requirement for the require-no-hard-coded-dependency-versions rule.",
"projectType": "devModule",
"severity": Object {
"severity": {
"severityType": "error",
},
}
Expand All @@ -21,12 +21,12 @@ Object {
exports[`require-no-hard-coded-dependency-versions when projectType is devModule succeeds when there are no hardcoded dependencies 1`] = `undefined`;

exports[`require-no-hard-coded-dependency-versions when projectType is module fails when there are hardcoded dependencies 1`] = `
Object {
{
"lintId": "require-no-hard-coded-dependency-versions",
"lintMessage": "The dependencies for this project have hard-coded versions that violates the require-no-hard-coded-dependency-versions rule:
[email protected] does not satisfy requirement for the require-no-hard-coded-dependency-versions rule.",
"projectType": "module",
"severity": Object {
"severity": {
"severityType": "error",
},
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`require-no-terra-base-peer-dependency-versions fails as a warning when versions do not meet the required version 1`] = `
Object {
{
"lintId": "require-no-terra-base-peer-dependency-versions",
"lintMessage": "The dependencies for this project do not have the minimum versions required for no terra base peer dependencies:
terra-action-footer@^1.0.0 does not satisfy range requirement for no terra base peer dependencies: terra-action-footer@>2.5.0",
"projectType": "module",
"severity": Object {
"severity": {
"severityType": "warn",
},
}
`;

exports[`require-no-terra-base-peer-dependency-versions fails when versions do not meet the required version 1`] = `
Object {
{
"lintId": "require-no-terra-base-peer-dependency-versions",
"lintMessage": "The dependencies for this project do not have the minimum versions required for no terra base peer dependencies:
[email protected] does not satisfy range requirement for no terra base peer dependencies: terra-action-footer@>2.5.0
Expand Down Expand Up @@ -90,7 +90,7 @@ Object {
[email protected] does not satisfy range requirement for no terra base peer dependencies: terra-toggle@>3.5.0
[email protected] does not satisfy range requirement for no terra base peer dependencies: terra-visually-hidden-text@>2.4.0",
"projectType": "devModule",
"severity": Object {
"severity": {
"severityType": "error",
},
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`require-theme-context-versions fails as a warning when versions do not meet the required version 1`] = `
Object {
{
"lintId": "require-theme-context-versions",
"lintMessage": "The dependencies for this project do not have the minimum versions required for theming context:
terra-action-footer@^1.0.0 does not satisfy range requirement for theming context: terra-action-footer@>=2.42.0",
"projectType": "module",
"severity": Object {
"severity": {
"severityType": "warning",
},
}
`;

exports[`require-theme-context-versions fails when versions do not meet the required version 1`] = `
Object {
{
"lintId": "require-theme-context-versions",
"lintMessage": "The dependencies for this project do not have the minimum versions required for theming context:
@cerner/terra-docs@<1.0.0 does not satisfy range requirement for theming context: @cerner/terra-docs@>=1.0.0
Expand Down Expand Up @@ -89,7 +89,7 @@ Object {
terra-time-input@<4.29.0 does not satisfy range requirement for theming context: terra-time-input@>=4.29.0
terra-toolbar@<1.8.0 does not satisfy range requirement for theming context: terra-toolbar@>=1.8.0",
"projectType": "module",
"severity": Object {
"severity": {
"severityType": "error",
},
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`custom-property-name does error with a mismatched name 1`] = `
Array [
Object {
[
{
"column": 9,
"endColumn": 47,
"endLine": 1,
Expand All @@ -15,8 +15,8 @@ Array [
`;

exports[`custom-property-name does error with a mismatched name with hyphen 1`] = `
Array [
Object {
[
{
"column": 9,
"endColumn": 49,
"endLine": 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`custom-property-namespace does error with no custom namespace 1`] = `
Array [
Object {
[
{
"column": 9,
"endColumn": 33,
"endLine": 1,
Expand All @@ -15,8 +15,8 @@ Array [
`;

exports[`custom-property-namespace does error with no default namespace 1`] = `
Array [
Object {
[
{
"column": 9,
"endColumn": 34,
"endLine": 1,
Expand Down
Loading
Loading