Skip to content

Commit 301530e

Browse files
committed
[skip ci] migrate moxios example, needed axios downgrade
1 parent 004bf2b commit 301530e

3 files changed

Lines changed: 25 additions & 31 deletions

File tree

package-lock.json

Lines changed: 11 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
},
1919
"license": "MIT",
2020
"dependencies": {
21-
"axios": "^1.6.3",
21+
"axios": "^0.27.2",
2222
"bcrypt": "^5.1.1",
2323
"express": "^4.18.2",
2424
"jest": "^29.7.0",
Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
const express = require("express");
2-
const moxios = require("moxios");
3-
const request = require("supertest");
4-
const axios = require("axios");
1+
import { test, describe, beforeEach, afterEach } from "node:test";
2+
import assert from "node:assert/strict";
53

6-
const hugo = (router = new express.Router()) => {
4+
import express, { Router } from "express";
5+
// note that moxios doesn't work with axios version >1
6+
import moxios from "moxios";
7+
import request from "supertest";
8+
import axios from "axios";
9+
10+
// @ts-ignore
11+
const hugo = (router = new Router()) => {
712
router.get("/hugo", async (request_, res) => {
813
const { data: userData } = await axios.get(
914
"https://api.github.com/users/HugoDF",
@@ -44,7 +49,8 @@ describe("GET /hugo", () => {
4449
});
4550
const app = initHugo();
4651
await request(app).get("/hugo");
47-
expect(moxios.requests.mostRecent().url).toBe(
52+
assert.equal(
53+
moxios.requests.mostRecent().url,
4854
"https://api.github.com/users/HugoDF",
4955
);
5056
});
@@ -60,7 +66,7 @@ describe("GET /hugo", () => {
6066
});
6167
const app = initHugo();
6268
const res = await request(app).get("/hugo");
63-
expect(res.body).toEqual({
69+
assert.deepEqual(res.body, {
6470
blog: "https://codewithhugo.com",
6571
location: "London",
6672
bio: "Developer, JavaScript",

0 commit comments

Comments
 (0)