Gathering detailed insights and metrics for cypress-auto-mock-http-request
Gathering detailed insights and metrics for cypress-auto-mock-http-request
Gathering detailed insights and metrics for cypress-auto-mock-http-request
Gathering detailed insights and metrics for cypress-auto-mock-http-request
npm install cypress-auto-mock-http-request
Typescript
Module System
Node Version
NPM Version
73.6
Supply Chain
94.4
Quality
75.4
Maintenance
100
Vulnerability
100
License
JavaScript (99.94%)
HTML (0.06%)
Total Downloads
8,598
Last Day
5
Last Week
11
Last Month
58
Last Year
1,251
57 Commits
1 Forks
4 Branches
2 Contributors
Updated on Aug 15, 2023
Latest Version
0.0.3
Package Id
cypress-auto-mock-http-request@0.0.3
Unpacked Size
41.24 kB
Size
9.14 kB
File Count
7
NPM Version
6.14.4
Node Version
12.17.0
Cumulative downloads
Total Downloads
Last Day
0%
5
Compared to previous day
Last Week
266.7%
11
Compared to previous week
Last Month
87.1%
58
Compared to previous month
Last Year
-30.3%
1,251
Compared to previous year
This repository is a copy of https://github.com/scottschafer/cypressautomocker. We have made this copy for an immediate need to use the library and the correction of specific issues found. We suggest using the original library because these same changes will be suggested to the original library
Integrating this tool into your web application involves a few steps:
Add the cypress-auto-mock-http-request to your project:
1npm install --save cypress-auto-mock-http-request
Add the cypress web hooks to your application.
1import installCypressHooks from 'cypress-auto-mock-http-request/include-in-webapp'; 2installCypressHooks();
Another option to do the same thing would be to include the following code in your HTML instead:
1<script src="node_modules/cypress-auto-mock-http-request/include-in-webapp/installCypressHooks-norequire.js">
Add the following to cypress/support/commands.js
1import registerAutoMockCommands from 'cypress-auto-mock-http-request/include-in-tests'; 2registerAutoMockCommands();
In each of your tests, add the following:
1 const MOCK_FILENAME = 'testCounter'; 2 3 before(() => { 4 cy.automock(MOCK_FILENAME); 5 }); 6 7 after(() => { 8 cy.automockEnd(); 9 });
This tool is built on top of the open-source testing platform Cypress.io to allow recording API results and replaying the APIs as a mock server.
There are three subfolders within the head directory:
To install and run the example, run the following:
cd example
npm install
npm run start
You should see Example app listening at http://localhost:1337
which means that the local server is running on port 1337. It will also open Cypress, allowing you to run the test.
The first time you run the test, our tool will record the API results to the file example/cypress/automocks/testCounter.json. The next time the test is run, it will automatically use the contents of the file to mock the APIs.
You can control the recording and playback behavior using the (optional) automocker field in cypress.json:
"automocker": {
"record": true,
"playback": true
}
The default (that is, if "automocker" doesn't exist) is to treat both record and playback as true, which means that it will automatically record API calls (if the proper commands are called in the tests) if the mock file does not exits, and will play them back as mocks if they do exist.
No vulnerabilities found.