Comments (8)
sorry to jump on this question but I am having an issue testing a service that uses the HTTPService
so wondered if there was an example of the spec file?
https://discord.com/channels/520622812742811698/520649487924985885/765515369116073984 some code examples of my issue and any discussion that comes after
from testing-nestjs.
Or can you give some advice do we need mock axios request for e2e test?
from testing-nestjs.
By "Axios" are you meaning the npm package, or the built in HttpService
that is a wrapper around axios?
from testing-nestjs.
By "Axios" are you meaning the npm package, or the built in
HttpService
that is a wrapper around axios?
What's the difference between these two ?
Consider that our service depend on other http service where we use axios (or fetch) to get data from
from testing-nestjs.
What's the difference between these two?
The built in HttpService
is a wrapper around axios and uses Observables, whereas axios the npm package is a direct http client that uses promises or callbacks, so the testing of the two is different.
How do your see this test going, are you using a package directly or a service as a wrapper? In my opinion one is easier to work with than the other when it comes to writing tests.
from testing-nestjs.
Well, i am using a npm package directly.
import axios from 'axios';
axios.get(url).then(res => {... })
BTW:
π€£what a coincidence i just saw your answer in this stackflow question
from testing-nestjs.
If this isn't about mocking a provider
in Nest, I would say that it falls out of the scope of what this repository is for. There are several tutorials and articles out there showing how you can use jest.mock()
and jest.spyOn()
along with other methods to mock npm packages in unit or e2e scopes, as Jest doesn't consider them different at all.
from testing-nestjs.
ok cool
from testing-nestjs.
Related Issues (20)
- About import {DocumentQuery} from 'mongoose' at mongo-sample
- Suggestion: convert testing-nestjs into monorepo with Lerna HOT 3
- [Question] How I mock another service method? HOT 8
- Suggestion: create tests for Prisma (alternative to TypeORM) HOT 7
- [FAILING TEST] Unit testing a NestJS Service that consumes a TypeORM Repository HOT 6
- [NEW TEST] Testing for interceptor failure HOT 3
- [NEW TEST] KnexJs Sample test HOT 1
- Multiple mocked dependencies with the same content HOT 5
- [NEW TEST] Bull HOT 4
- Prisma transactions and rollbacks now available HOT 2
- [NEW TEST] - (Contract Testing) - Incorporate NestJS Consumer Driven Contract testing with nestjs-pact HOT 6
- README refers to non-existing cat.integration.spec.ts HOT 3
- Test against Solidity smart contracts
- [NEW TEST] Tests for mikro-orm
- [NEW TEST] Sequelize transactions HOT 1
- Add code comment for documenting the tests. HOT 1
- Unable to commit the file in file-up-and-down-sample HOT 1
- Can't push to sidebranch for PR - getting permission denied HOT 1
- I can't seem to make the tests fails anywhere so far HOT 3
- npm install doesn't work
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 testing-nestjs.