随笔分类 - Unit Testing
摘要:const { TestScheduler } = require("rxjs/testing"); const { map, take, delay, mapTo, catchError } = require("rxjs/operators"); const { concat, from, of
阅读全文
摘要:const { TestScheduler } = require("rxjs/testing"); const { map, take, delay } = require("rxjs/operators"); const { concat, from } = require("rxjs"); d
阅读全文
摘要:const { TestScheduler } = require("rxjs/testing"); const { map, take } = require("rxjs/operators"); const { concat, from } = require("rxjs"); describe
阅读全文
摘要:const { TestScheduler } = require("rxjs/testing"); const { map, take } = require("rxjs/operators"); const { concat } = require("rxjs"); describe("Marb
阅读全文
摘要:const { TestScheduler } = require("rxjs/testing"); const { map } = require("rxjs/operators"); const { concat } = require("rxjs"); describe("Marble tes
阅读全文
摘要:CrudController: 查看代码 export const getOne = model => async (req, res) => { try { const doc = model .findOne({ createdBy: req.user._id, _id: req.params.
阅读全文
摘要:Model: import mongoose from 'mongoose' const itemSchema = new mongoose.Schema( { name: { type: String, required: true, trim: true, maxlength: 50 }, st
阅读全文
摘要:Model: import mongoose from 'mongoose' const itemSchema = new mongoose.Schema( { name: { type: String, required: true, trim: true, maxlength: 50 }, st
阅读全文
摘要:server.js: import itemRouter from './resources/item/item.router' export const app = express() app.use('/api/item', itemRouter) item.router.js import {
阅读全文
摘要:Assumption: Run the testing code only if when the condition is match, otherwise, test will be ignored @Test void runTestIf() { System.out.print("Curre
阅读全文
摘要:Let’s add a test for an edge case that responds with an error message. In this lesson we’ll talk about the value of using the toMatchInlineSnapshot as
阅读全文
摘要:You can have a untils folder under root folder, to let jest include your files, you can do: const path = require('path') module.exports = { displayNam
阅读全文
摘要:Code: import {UnauthorizedError} from 'express-jwt' function errorMiddleware(error, req, res, next) { if (res.headersSent) { next(error) } else if (er
阅读全文
摘要:Jest has a test-generation feature built-in called test.each which is great, but I don’t particularly like it’s API. Instead, we’re going to use an op
阅读全文
摘要:One of the most crucial things you can do when writing tests is ensuring that the error message explains the problem as clearly as possible so it can
阅读全文
摘要:In Postman, you can create a collection of API requests. Those collection can be save into json file as well. { "info": { "_postman_id": "9c5a8003-1c5
阅读全文
摘要:Testing JWT proteceted endpoint: /** * HTTP POST /tours/{tourId}/ratings */ @Test public void createTourRating() throws Exception { restTemplate.excha
阅读全文
摘要:Controller: @RestController @RequestMapping(path = "/ratings") public class RatingController { private static final Logger LOGGER = LoggerFactory.getL
阅读全文
摘要:Service: package com.example.ec.service; import com.example.ec.domain.Tour; import com.example.ec.domain.TourRating; import com.example.ec.repo.TourRa
阅读全文
摘要:Controller: @Controller @RequestMapping("/reservations") public class RoomReservationWebController { @Autowired private ReservationService reservation
阅读全文