Skip to content

Commit

Permalink
use sfdx-lwc-jest instead of lwc-jest (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Trevor committed Aug 9, 2019
1 parent ed38ab2 commit d7598f1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion messages/setup.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"errorNpmNotFound": "npm command not found. Verify npm is properly installed and try again.",
"errorNodeVersion": "Node.js version too low. Version 8.12.0 or higher required. Found version %s",
"errorNoPackageJson": "No package.json found at root of project. Run \"npm init\" to create one.",
"errorLwcJestInstall": "Error installing @salesforce/lwc-jest: %o",
"errorLwcJestInstall": "Error installing @salesforce/sfdx-lwc-jest: %o",
"logSuccess": "Test setup complete.",
"logFileUpdatesStart": "Updating files...",
"logFileUpdatesEnd": "File modifications complete.",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/force/lightning/lwc/test/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default class Run extends SfdxCommand {
private getExecutablePath() {
const projectPath = this.project.getPath();
const nodeModulePath = process.platform === 'win32' ?
path.join('@salesforce', 'lwc-jest', 'bin', 'lwc-jest') :
path.join('@salesforce', 'sfdx-lwc-jest', 'bin', 'lwc-jest') :
path.join('.bin', 'lwc-jest');

const executablePath = path.join(projectPath, 'node_modules', nodeModulePath);
Expand Down
8 changes: 4 additions & 4 deletions src/commands/force/lightning/lwc/test/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const testScripts = {
'test:unit:watch': 'lwc-jest --watch'
};

const jestConfig = `const { jestConfig } = require('@salesforce/lwc-jest/config');
const jestConfig = `const { jestConfig } = require('@salesforce/sfdx-lwc-jest/config');
module.exports = {
...jestConfig,
// add any custom configurations here
Expand Down Expand Up @@ -134,14 +134,14 @@ export default class Setup extends SfdxCommand {
}

private installLwcJest(): void {
this.ux.log('Installing @salesforce/lwc-jest node package...');
this.ux.log('Installing @salesforce/sfdx-lwc-jest node package...');
let lwcJestInstallRet;
const yarnLockExists = fs.existsSync(path.join(this.project.getPath(), 'yarn.lock'));
if (yarnLockExists) {
this.ux.log('Detected yarn.lock file, using yarn commands');
lwcJestInstallRet = spawnSync('yarn', ['add', '--dev', '@salesforce/lwc-jest'], { stdio: 'inherit' });
lwcJestInstallRet = spawnSync('yarn', ['add', '--dev', '@salesforce/sfdx-lwc-jest'], { stdio: 'inherit' });
} else {
lwcJestInstallRet = spawnSync('npm', ['install', '--save-dev', '@salesforce/lwc-jest'], { stdio: 'inherit' });
lwcJestInstallRet = spawnSync('npm', ['install', '--save-dev', '@salesforce/sfdx-lwc-jest'], { stdio: 'inherit' });
}
if (lwcJestInstallRet.error) {
throw new SfdxError(messages.getMessage('errorLwcJestInstall', [lwcJestInstallRet.error.message]));
Expand Down
2 changes: 1 addition & 1 deletion test/commands/lwc/test/setup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ describe('force:lightning:lwc:test:setup', () => {
.command(['force:lightning:lwc:test:setup'])
.it('write a jest.config.js file if no existing config found', ctx => {
expect(fileWriterStub.queueWrite.args[0][0]).to.contain('jest.config.js');
expect(fileWriterStub.queueWrite.args[0][1]).to.contain("const { jestConfig } = require('@salesforce/lwc-jest/config'");
expect(fileWriterStub.queueWrite.args[0][1]).to.contain("const { jestConfig } = require('@salesforce/sfdx-lwc-jest/config'");
});
});

Expand Down

0 comments on commit d7598f1

Please sign in to comment.