From 152b8e9a64623ce5677c1ef3cd802f7291855611 Mon Sep 17 00:00:00 2001 From: chris48s Date: Sat, 18 Jan 2025 19:16:59 +0000 Subject: [PATCH] fix badge-maker package tests (#10809) --- .../{make-badge.spec.js => make-badge.spec.mjs.js} | 0 badge-maker/lib/badge-cli.spec.mjs | 8 ++++++-- badge-maker/lib/index.spec.mjs | 2 +- badge-maker/lib/make-badge.spec.mjs | 2 +- package.json | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) rename __snapshots__/{make-badge.spec.js => make-badge.spec.mjs.js} (100%) diff --git a/__snapshots__/make-badge.spec.js b/__snapshots__/make-badge.spec.mjs.js similarity index 100% rename from __snapshots__/make-badge.spec.js rename to __snapshots__/make-badge.spec.mjs.js diff --git a/badge-maker/lib/badge-cli.spec.mjs b/badge-maker/lib/badge-cli.spec.mjs index b9d5fd5dcb7f9..ad1a15de3e66a 100644 --- a/badge-maker/lib/badge-cli.spec.mjs +++ b/badge-maker/lib/badge-cli.spec.mjs @@ -1,12 +1,16 @@ 'use strict' import path from 'path' +import { fileURLToPath } from 'url' import { spawn } from 'child-process-promise' import { expect, use } from 'chai' -use(require('sinon-chai')) +import sinonChai from 'sinon-chai' +use(sinonChai) + +const dirName = path.dirname(fileURLToPath(import.meta.url)) function runCli(args) { - return spawn('node', [path.join(__dirname, 'badge-cli.js'), ...args], { + return spawn('node', [path.join(dirName, 'badge-cli.js'), ...args], { capture: ['stdout'], }) } diff --git a/badge-maker/lib/index.spec.mjs b/badge-maker/lib/index.spec.mjs index d1c508f37c081..5638ff66df11b 100644 --- a/badge-maker/lib/index.spec.mjs +++ b/badge-maker/lib/index.spec.mjs @@ -1,7 +1,7 @@ 'use strict' import { expect } from 'chai' -import { makeBadge, ValidationError } from '.' +import { makeBadge, ValidationError } from './index.js' describe('makeBadge function', function () { it('should produce badge with valid input', async function () { diff --git a/badge-maker/lib/make-badge.spec.mjs b/badge-maker/lib/make-badge.spec.mjs index fb9c3d96e1c29..f91229446f862 100644 --- a/badge-maker/lib/make-badge.spec.mjs +++ b/badge-maker/lib/make-badge.spec.mjs @@ -4,7 +4,7 @@ import { test, given, forCases } from 'sazerac' import { expect } from 'chai' import snapshot from 'snap-shot-it' import prettier from 'prettier' -import makeBadge from './make-badge' +import makeBadge from './make-badge.js' async function expectBadgeToMatchSnapshot(format) { snapshot(await prettier.format(makeBadge(format), { parser: 'html' })) diff --git a/package.json b/package.json index ce667616de55f..025b1ce24029d 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,7 @@ "danger": "danger", "test:e2e": "cypress run", "test:core": "cross-env TZ='UTC' NODE_CONFIG_ENV=test mocha \"core/**/*.spec.js\" \"lib/**/*.spec.js\" \"services/**/*.spec.js\"", - "test:package": "mocha \"badge-maker/**/*.spec.js\"", + "test:package": "mocha \"badge-maker/**/*.spec.@(mjs|js)\"", "test:entrypoint": "cross-env NODE_CONFIG_ENV=test mocha entrypoint.spec.js", "test:integration": "cross-env NODE_CONFIG_ENV=test mocha \"core/**/*.integration.js\" \"services/**/*.integration.js\"", "test:services": "cross-env NODE_CONFIG_ENV=test mocha core/service-test-runner/cli.js",