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

954 - Add tests coverage #977

Merged
merged 8 commits into from
May 10, 2022
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ node_modules
# Cypress
cypress/videos
cypress/screenshots

# Coverage
coverage
.nyc_output
6 changes: 6 additions & 0 deletions cypress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,9 @@ https://docs.cypress.io/guides/references/configuration#cypress-json
[app_action]: (https://www.cypress.io/blog/2019/01/03/stop-using-page-objects-and-start-using-app-actions/)

*[[Back to top] 🔝](#concepts)*

### Coverage
Have to run a separate command to instrument the code (instrument = add helper code, that tracks when code was executed)
`npm run start-dev:cov`

Then can run other e2e commands
18 changes: 15 additions & 3 deletions cypress/integration/common/deal-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ export class E2eDealsApi {
return Cypress.firestoreService;
}

private static getDealService() {
// @ts-ignore - Hack to access dealService inside Cypress
return Cypress.dealService;
}
Comment on lines +29 to +32
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dkent600
okay to have this changes in this PR, or do you prefer separate?


private static getDataSourceDeals(): FirestoreDealsService<
IDealTokenSwapDocument,
IDealRegistrationTokenSwap
Expand Down Expand Up @@ -179,9 +184,16 @@ export class E2eDealsApi {
* 2. Interact with Firestore
*/
return cy.then(async () => {
const firestoreService = E2eDealsApi.getFirestoreService();

const createdDeal = await firestoreService.createDealTokenSwap(registrationData);
const dealService = E2eDealsApi.getDealService();

/**
* Have to use `@ts-ignore`, because we cannot import `DealService` in cypress.
* Cannot import, because of bundling issues (bundling does not support importing Aurelia code)
*/
// @ts-ignore
await dealService.ensureInitialized();
// @ts-ignore
const createdDeal = await dealService.createDeal(registrationData) as IDealTokenSwapDocument;

E2eDeals.setDeal(createdDeal);

Expand Down
3 changes: 3 additions & 0 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,7 @@ module.exports = (on, config) => {
]
}
}));

require('@cypress/code-coverage/task')(on, config)
return config
};
2 changes: 2 additions & 0 deletions cypress/support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
// Import commands.js using ES2015 syntax:
import './commands';

import '@cypress/code-coverage/support'

// Alternatively you can use CommonJS syntax:
// require('./commands');

Expand Down
Loading