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