Skip to content

test dynamic base url #62

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"max-len": ["error", { "code": 250 }],
"jest/no-large-snapshots": ["warn", { "maxSize": 12, "inlineMaxSize": 6 }],
"jest/no-jasmine-globals": "off",
"jest/expect-expect": "off",
"quotes": [1, "single", { "allowTemplateLiterals": true }],
"@angular-eslint/component-selector": [
"error",
Expand Down
6 changes: 2 additions & 4 deletions cypress/integration/dashboard.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
describe('dashboard', () => {

before(() => cy.visit('/'));

it('should default to dashboard', () => {
cy.contains('Test Tour of Heroes');
cy.url().should('include', 'dashboard');
});

it('should nav to a heroes click and nav to heroes list on cancel, and nav back to dashboard ', () => {
it('should nav to a heroes click and nav to heroes list on cancel, and nav back to dashboard', () => {
cy.get('.hero').first().click();
cy.url().should('include', '/heroes/');

Expand All @@ -18,6 +17,5 @@ describe('dashboard', () => {
cy.get('[routerlink="/dashboard"]').click();
cy.url().should('include', 'dashboard');
cy.get('.hero').should('have.length', 4);
})

});
});
32 changes: 32 additions & 0 deletions cypress/integration/dynanic-url.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* eslint-disable jest/valid-expect-in-promise */
describe('dynamic url', () => {
// Question: can we set a different baseUrl in a before block?
// setting baseUrl for it block works, no support for before block
// if using Cypress.config, the value gets sets for the entire test suite
// what can we do?

it('should use customized baseUrl', { baseUrl: 'https://d1kaucldkbcik4.cloudfront.net' }, () => {
// cy.then(() => {
// Cypress.config('baseUrl', 'https://d1kaucldkbcik4.cloudfront.net');
// });
cy.visit('/');
cy.url().should('contain', 'https://d1kaucldkbcik4.cloudfront.net');
cy.contains('Test Tour of Heroes');
cy.url().should('include', 'dashboard');
});

it('should use default baseUrl', () => {
cy.visit('/');
cy.url().should('contain', 'http://localhost:4200');
cy.get('.hero').first().click();
cy.url().should('include', '/heroes/');

cy.get('.qa-cancel').click();
cy.url().should('include', '/heroes');
cy.get('.heroes >').should('have.length', 10);

cy.get('[routerlink="/dashboard"]').click();
cy.url().should('include', 'dashboard');
cy.get('.hero').should('have.length', 4);
});
});