Skip to content

Commit

Permalink
feat(nx): update to cypress 3.3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio-martinez authored and vsavkin committed Jun 4, 2019
1 parent fc09072 commit 00b93fa
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"conventional-changelog-cli": "^1.3.21",
"copy-webpack-plugin": "5.0.3",
"cosmiconfig": "^4.0.0",
"cypress": "3.3.1",
"cypress": "~3.3.1",
"cz-conventional-changelog": "^2.1.0",
"document-register-element": "^1.13.1",
"dotenv": "6.2.0",
Expand Down
1 change: 0 additions & 1 deletion packages/angular/src/schematics/ng-add/ng-add.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ describe('ng-add', () => {
const { devDependencies } = readJsonInTree(tree, 'package.json');
expect(devDependencies['@nrwl/cypress']).toBeDefined();
expect(devDependencies['cypress']).toBeDefined();
expect(devDependencies['@types/jquery']).toBeDefined();
});

it('should set defaults', async () => {
Expand Down
8 changes: 7 additions & 1 deletion packages/cypress/migrations.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
{
"schematics": {}
"schematics": {
"update-8.1.0": {
"version": "8.1.0",
"description": "Update cypress",
"factory": "./src/migrations/update-8-1-0/update-8-1-0"
}
}
}
34 changes: 34 additions & 0 deletions packages/cypress/src/migrations/update-8-1-0/update-8-1-0.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Tree } from '@angular-devkit/schematics';
import { SchematicTestRunner } from '@angular-devkit/schematics/testing';
import { serializeJson } from '@nrwl/workspace';

import * as path from 'path';

describe('Update 8.1.0', () => {
let initialTree: Tree;
let schematicRunner: SchematicTestRunner;

beforeEach(() => {
initialTree = Tree.empty();
initialTree.create(
'package.json',
serializeJson({
scripts: {}
})
);
schematicRunner = new SchematicTestRunner(
'@nrwl/cypress',
path.join(__dirname, '../../../migrations.json')
);
});

it('should update cypress', async () => {
const result = await schematicRunner
.runSchematicAsync('update-8.1.0', {}, initialTree)
.toPromise();

const { devDependencies } = JSON.parse(result.readContent('package.json'));

expect(devDependencies.cypress).toEqual('~3.3.1');
});
});
33 changes: 33 additions & 0 deletions packages/cypress/src/migrations/update-8-1-0/update-8-1-0.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {
Rule,
chain,
SchematicContext,
Tree
} from '@angular-devkit/schematics';
import { updateJsonInTree } from '@nrwl/workspace';
import { stripIndents } from '@angular-devkit/core/src/utils/literals';

function displayInformation(host: Tree, context: SchematicContext) {
context.logger.info(
stripIndents`Cypress has been updated to a version that improves network speed by 300%!
Additionally, this resolves an issue where '@types/jquery' needed to be temporarily included in your 'package.json'.
If you're not using '@types/jquery' in your project otherwise, you may now remove it from your 'devDependencies'.`
);
}

export default function(): Rule {
return chain([
updateJsonInTree('package.json', json => {
json.devDependencies = json.devDependencies || {};

json.devDependencies = {
...json.devDependencies,
cypress: '~3.3.1'
};

return json;
}),
displayInformation
]);
}
2 changes: 0 additions & 2 deletions packages/cypress/src/schematics/ng-add/ng-add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ function checkDependenciesInstalled(): Rule {
const dependencyList: { name: string; version: string }[] = [];
if (!packageJson.devDependencies.cypress) {
dependencyList.push({ name: 'cypress', version: cypressVersion });
// NOTE: Need to be removed on the next Cypress release (=>3.1.1)
dependencyList.push({ name: '@types/jquery', version: '3.3.6' });
}
if (!packageJson.devDependencies['@nrwl/cypress']) {
dependencyList.push({ name: '@nrwl/cypress', version: nxVersion });
Expand Down
2 changes: 1 addition & 1 deletion packages/cypress/src/utils/versions.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const nxVersion = '*';
export const cypressVersion = '3.1.0';
export const cypressVersion = '~3.3.1';

0 comments on commit 00b93fa

Please sign in to comment.