From 4528459de525fb603d6738186f11598dec943598 Mon Sep 17 00:00:00 2001 From: Rifa Achrinza <25147899+achrinza@users.noreply.github.com> Date: Mon, 26 Feb 2024 21:27:44 +0800 Subject: [PATCH] test: convert to ES Module Signed-off-by: Rifa Achrinza <25147899+achrinza@users.noreply.github.com> --- test/{handler.test.js => handler.test.mjs} | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) rename test/{handler.test.js => handler.test.mjs} (98%) diff --git a/test/handler.test.js b/test/handler.test.mjs similarity index 98% rename from test/handler.test.js rename to test/handler.test.mjs index 9e502de..d1b04f7 100644 --- a/test/handler.test.js +++ b/test/handler.test.mjs @@ -5,13 +5,15 @@ 'use strict'; -const cloneAllProperties = require('../lib/clone.js'); -const debug = require('debug')('test'); -const expect = require('chai').expect; -const express = require('express'); -const strongErrorHandler = require('..'); -const supertest = require('supertest'); -const util = require('util'); +import cloneAllProperties from '../lib/clone.js'; +import debugFactory from 'debug'; +import express from 'express'; +import strongErrorHandler from '../lib/handler.js'; +import supertest from 'supertest'; +import util from 'node:util'; +import {expect} from 'chai'; + +const debug = debugFactory('test'); describe('strong-error-handler', function() { before(setupHttpServerAndClient); @@ -137,8 +139,7 @@ describe('strong-error-handler', function() { // the error name & message expect(msg).to.contain('TypeError: ERROR-NAME'); // the stack - expect(msg).to.contain(__filename); - + expect(msg).to.contain(import.meta.url); done(); }); }); @@ -161,7 +162,7 @@ describe('strong-error-handler', function() { expect(msg).to.contain('TypeError: ERR1'); expect(msg).to.contain('Error: ERR2'); // verify that stacks are included too - expect(msg).to.contain(__filename); + expect(msg).to.contain(import.meta.url); done(); });