Comments (9)
Hi @mbruggenwirth , no, unfortunately I had not as much time for the project as I'd like. I hope to release the TypeScript migration soon, and then I'll be able to work on this feature. But I can't say when it will be ready 😞 I will notify it on this issue as soon as I start working on it.
from main.
@mbruggenwirth , I hope it will be available sometime in the next 3 months. I'm currently finishing the migration of the whole project to TypeScript, and improving the architecture to make easier to expose the next big feature to the API, which in fact is to support spying routes.
from main.
Hi @mbruggenwirth ,
First of all, thanks for the feedback 😃 . I have planned to add support for spying routes, and, when that feature is implemented, it would be possible to add new cypress commands allowing to write assertions about them.
from main.
@javierbrea awesome! Any idea when this will be on the schedule.
It will help me with my internal mock-server pitch.
from main.
@javierbrea any update about this enhancement?
from main.
@javierbrea any update about this enhancement?
from main.
Is there any progress on this issue?
from main.
Not for the moment @mbruggenwirth 😞 . Anyway, let me think about how to implement it by using a plugin, so you may implement it by yourself until it is added to the core features. I hope to answer soon with a proposal 😃
from main.
I thought I'd share my workaround as I couldn't manage to figure out how to get plugins to do this. Basically I changed to run an express proxy in front of mocks-server so I could catch the responses.
const path = require('path');
const express = require('express');
const { createServer } = require('@mocks-server/main');
// this just gets the root of my repository folder
const { workspaceRoot } = require('nx/src/utils/workspace-root.js');
const {
createProxyMiddleware,
fixRequestBody,
} = require('http-proxy-middleware');
const core = createServer({
server: {
port: 3101,
},
plugins: {
inquirerCli: {
enabled: typeof process.env.CI === 'undefined',
},
},
files: {
enabled: true,
path: path.join(workspaceRoot, 'apps/mock-server/mocks'),
babelRegister: {
enabled: true,
options: {
presets: ['@babel/env', '@babel/preset-typescript'],
},
},
},
});
core.start();
const app = express();
let requests = [];
app.use(express.json());
app.delete('/test-requests', (req, res) => {
requests = [];
res.status(200).end();
});
app.get('/test-requests', (req, res) => {
res.json(requests);
});
const proxy = express();
proxy.use(express.json());
proxy.use(
createProxyMiddleware({
target: 'http://localhost:3101',
changeOrigin: true,
onProxyReq: (proxyReq, req, res, options) => {
requests.push({
url: req.url,
method: req.method,
headers: req.headers,
body: req.body,
params: req.params,
});
return fixRequestBody(proxyReq, req, res, options);
},
}),
);
app.listen(3102);
proxy.listen(3100);
Then in cypress I do;
beforeEach(() => {
cy.request('DELETE', 'http://localhost:3102/test-requests');
});
Cypress.Commands.add('getApiSubmits', () =>
cy
.request<
(Record<string, string> & { body: object })[]
>('GET', 'http://localhost:3102/test-requests')
.then((res) =>
res.body
.filter((r) => r.method === 'PUT' && r.url.startsWith('/responses/'))
.map((r) => r.body),
),
);
from main.
Related Issues (20)
- Fixes for vulnerabilities in yaml, minimist and got dependencies HOT 1
- Error resolving openapi $ref: JSON Pointer points to missing location: #/components/schemas/Pet HOT 2
- OpenAPI: support generating variants from examples in response schemas HOT 4
- OpenAPI: Variants are not generated for responses with a single `example` key HOT 4
- Adding cypress commands throw webpack error: Can't resolve 'node:buffer' HOT 4
- quicktype for automated mocks? HOT 1
- Alert about not loaded files in routes folder HOT 5
- OpenAPI remote example failing due to stringified json HOT 1
- Babel configuration ignored in docker container HOT 7
- Problems with Query Params path-to-regexp HOT 1
- File collections.json cannot be found when it is in the CWD HOT 1
- Import mockjs or other modules
- Publish Docker multi-platform images
- Please provide support of HAR files as a source of mocks HOT 1
- JavaScript API: createServer command with config object throws error "unknown option '--config'" HOT 2
- [object Object] header in OpenApi mocks
- Support TypeScript without the need for Babel HOT 1
- Creating-an-instance-with-pre-installed-plugins fails to start HOT 2
- mocks-server-lite - An Alternative HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from main.