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

Cypress testing #29

Open
wants to merge 2 commits 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
41 changes: 40 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,45 @@ Or start all of them together using
pm2 start dist/apps/bg/main.js --name beckn-bg
```

## Cypress Testing

1. Install the required dependencies using the package manager of your choice (yarn preferred).

```bash
yarn install
```
This command will install all the necessary dependencies defined in the package.json file, including Cypress.

2. Run the Cypress tests in the terminal. This will execute the tests in headless mode and output the results to the console.

```bash
npx cypress run
```

The Cypress Test Runner will start running the tests and display the test results and logs in the terminal.

Alternatively, you can open the Cypress Test Runner in a separate interface to run and view your tests:

```bash
npx cypress open
```

This command will open the Cypress Test Runner, which provides a graphical interface to manage and execute your Cypress tests.

From the Test Runner, you can select a specific test file or run all tests. It also provides real-time reloading of tests as you make changes, allowing for a faster development workflow.

Cypress Test Runner also offers additional features like debugging, screenshots, and video recording of test runs.

3. Follow the instructions provided by the Cypress Test Runner to interact with and inspect the tests.

Choose a reason for hiding this comment

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

The concerned point no. 3 talks about working of "cypress test runner" in general which can be omitted as the above points convey clearly how to run the tests.

Removing this can help keep the Readme file clear and concise.


* To run a specific test or test suite, click on the corresponding file or test case in the Cypress Test Runner.

* The Test Runner will automatically open a browser window and execute the selected test(s) within it.

* You can view the test execution, logs, and assertions in the Test Runner interface.

* To debug your tests, set breakpoints in your test code, and use the Cypress DevTools to inspect the application under test.

## Related Repositories

- [Mock Provider (Swayam)](https://github.com/Samagra-Development/swayam-wrapper)
Expand All @@ -153,4 +192,4 @@ Follow [this guide](https://github.com/sanjay95/BECKN-Integration-to-Gateway/blo
## Stay in touch

- Author: [Yash Mittal](https://github.com/techsavvyash)
- Mentor on the project: [Chakshu Gautam](https://github.com/ChakshuGautam)
- Mentor on the project: [Chakshu Gautam](https://github.com/ChakshuGautam)
9 changes: 9 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig } from "cypress";

export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
8 changes: 8 additions & 0 deletions cypress/e2e/home.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
describe('Home tests', () => {
it('should visit the homepage', () => {
cy.visit('https://ui.dsep.samagra.io/courses');
cy.contains('IIT Bombay').should('be.visible');
cy.contains('Add to List').first().click();
cy.contains('Go To Class').should('be.visible');
});
});
5 changes: 5 additions & 0 deletions cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
37 changes: 37 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
20 changes: 20 additions & 0 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.ts is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

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