Skip to content

Commit

Permalink
fix!: update dependencies, including jest (#335)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Jest updated from v27 to v28

Fixes #319
  • Loading branch information
nolanlawson committed Aug 10, 2023
1 parent bcece32 commit a007e2a
Show file tree
Hide file tree
Showing 6 changed files with 1,035 additions and 1,359 deletions.
41 changes: 19 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,35 +32,32 @@
"release:publish": "npm publish --access public --registry=https://registry.npmjs.org",
"test": "jest"
},
"//": {
"chalk": "Cannot update to chalk@5.0.0 because it requires ESM adoption https://github.com/chalk/chalk/releases/tag/v5.0.0"
},
"dependencies": {
"@lwc/compiler": "3.0.1",
"@lwc/engine-dom": "3.0.1",
"@lwc/engine-server": "2.49.1",
"@lwc/jest-preset": "12.0.3",
"@lwc/jest-resolver": "12.0.3",
"@lwc/jest-serializer": "12.0.3",
"@lwc/jest-transformer": "12.0.3",
"@lwc/module-resolver": "3.0.1",
"@lwc/synthetic-shadow": "3.0.1",
"@lwc/wire-service": "3.0.1",
"@lwc/compiler": "3.1.3",
"@lwc/engine-dom": "3.1.3",
"@lwc/engine-server": "3.1.3",
"@lwc/jest-preset": "13.0.0",
"@lwc/jest-resolver": "13.0.0",
"@lwc/jest-serializer": "13.0.0",
"@lwc/jest-transformer": "13.0.0",
"@lwc/module-resolver": "3.1.3",
"@lwc/synthetic-shadow": "3.1.3",
"@lwc/wire-service": "3.1.3",
"@salesforce/wire-service-jest-util": "4.0.1",
"chalk": "^4.1.2",
"fast-glob": "^3.2.12",
"jest": "27.4.7",
"fast-glob": "^3.3.1",
"jest": "29.6.2",
"jest-environment-jsdom": "29.6.2",
"yargs": "~17.7.2"
},
"devDependencies": {
"@babel/core": "^7.22.5",
"@babel/eslint-parser": "^7.22.5",
"@babel/plugin-proposal-decorators": "^7.22.5",
"eslint": "^8.43.0",
"@babel/core": "^7.22.10",
"@babel/eslint-parser": "^7.22.10",
"@babel/plugin-proposal-decorators": "^7.22.10",
"eslint": "^8.46.0",
"husky": "^8.0.3",
"isbinaryfile": "^5.0.0",
"lint-staged": "^13.2.2",
"prettier": "^2.8.8"
"lint-staged": "^13.2.3",
"prettier": "^3.0.1"
},
"lint-staged": {
"*.js": "eslint",
Expand Down
17 changes: 13 additions & 4 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,19 @@ const { PROJECT_ROOT, getModulePaths } = require('./utils/project.js');

function getCoveragePaths() {
const modulePaths = getModulePaths();
return modulePaths.map((p) => {
// convert back to forward slashes here on Windows for Jest to be happy
return p.replace(/\\/g, '/') + '/**/*.js';
});
return modulePaths
.map((p) => {
// convert back to forward slashes here on Windows for Jest to be happy
const prefix = p.replace(/\\/g, '/');
return [
// Note no `*.js` here - Jest will not find `.js` files unless you use a bare `*`
prefix + '/**/*',
// Specifically exclude HTML/CSS files since Jest doesn't understand the syntax
'!' + prefix + '/**/*.html',
'!' + prefix + '/**/*.css',
];
})
.flat();
}

const jestConfig = {
Expand Down
14 changes: 11 additions & 3 deletions src/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,22 @@

/* eslint-disable no-console */

const chalk = require('chalk');
function blue(message) {
// equivalent to chalk.blue()
return `\x1B[34m${message}\x1B[39m`;
}

function red(message) {
// equivalent to chalk.red()
return `\x1B[31m${message}\x1B[39m`;
}

function info(message) {
console.log(`${chalk.blue('info')} ${message}`);
console.log(`${blue('info')} ${message}`);
}

function error(message) {
console.error(`${chalk.red('error')} ${message}`);
console.error(`${red('error')} ${message}`);
}

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion tests/__snapshots__/help.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Options:
--debug Run tests in debug mode
(https://jestjs.io/docs/en/troubleshooting)
[boolean] [default: false]
--skipApiVersionCheck Disable the \\"sourceApiVersion\\" field check before
--skipApiVersionCheck Disable the "sourceApiVersion" field check before
running tests. **Warning** By disabling this check
you risk running tests against stale versions of
the framework. See details here:
Expand Down
8 changes: 6 additions & 2 deletions tests/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ const { jestConfig } = require('../src/config');

test('coveragePaths correctly build', () => {
expect(jestConfig.collectCoverageFrom).toStrictEqual([
'force-app/main/unix/lwc/**/*.js',
'force-app/main/windows/lwc/**/*.js',
'force-app/main/unix/lwc/**/*',
'!force-app/main/unix/lwc/**/*.html',
'!force-app/main/unix/lwc/**/*.css',
'force-app/main/windows/lwc/**/*',
'!force-app/main/windows/lwc/**/*.html',
'!force-app/main/windows/lwc/**/*.css',
]);
});
Loading

0 comments on commit a007e2a

Please sign in to comment.