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

use sfdx-lwc-jest instead of lwc-jest #2

Merged
merged 1 commit into from
Aug 9, 2019
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
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