Skip to content

Commit a3c7872

Browse files
committed
ci: add packaging test workflow and fix unit tests for esModuleInterop
1 parent e13c568 commit a3c7872

File tree

5 files changed

+11
-22
lines changed

5 files changed

+11
-22
lines changed

mocha/setup.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
1-
import * as chai from "chai";
2-
import * as chaiAsPromisedModule from "chai-as-promised";
3-
import * as nockModule from "nock";
4-
5-
// Normalize CommonJS exports so ts-node (Node.js 20) and Node.js 22's strip-only loader
6-
// both receive callable modules without relying on esModuleInterop.
7-
type ChaiPlugin = Parameters<typeof chai.use>[0];
8-
type NockModule = typeof nockModule;
9-
10-
const chaiAsPromisedExport = chaiAsPromisedModule as ChaiPlugin & { default?: ChaiPlugin };
11-
const chaiAsPromised = chaiAsPromisedExport.default ?? chaiAsPromisedExport;
12-
const nockExport = nockModule as NockModule & { default?: NockModule };
13-
const nock = nockExport.default ?? nockExport;
1+
import chai from "chai";
2+
import chaiAsPromised from "chai-as-promised";
3+
import nock from "nock";
144

155
chai.use(chaiAsPromised);
16-
17-
nock.disableNetConnect();
6+
nock.disableNetConnect();

spec/common/config.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
// SOFTWARE.
2222

2323
import { expect } from "chai";
24-
import * as fs from "fs";
25-
import * as process from "process";
24+
import fs from "fs";
2625
import * as sinon from "sinon";
2726

2827
import { firebaseConfig, resetCache } from "../../src/common/config";

spec/fixtures/mockrequest.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { EventEmitter } from 'node:stream';
22

3-
import * as jwt from 'jsonwebtoken';
4-
import * as jwkToPem from 'jwk-to-pem';
5-
import * as nock from 'nock';
3+
import jwt from 'jsonwebtoken';
4+
import jwkToPem from 'jwk-to-pem';
5+
import nock from 'nock';
66
import * as mockJWK from '../fixtures/credential/jwk.json';
77
import * as mockKey from '../fixtures/credential/key.json';
88

src/common/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { AppOptions } from "firebase-admin/app";
2-
import { readFileSync } from "fs";
2+
import fs from "fs";
33
import * as path from "path";
44

55
import * as logger from "../logger";
@@ -29,7 +29,7 @@ export function firebaseConfig(): AppOptions | null {
2929
// explicitly state that the user can set the env to a file:
3030
// https://firebase.google.com/docs/admin/setup#initialize-without-parameters
3131
if (!env.startsWith("{")) {
32-
env = readFileSync(path.join(process.env.PWD, env)).toString("utf8");
32+
env = fs.readFileSync(path.join(process.env.PWD, env)).toString("utf8");
3333
}
3434

3535
cache = JSON.parse(env);

tsconfig.release.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"stripInternal": true,
1010
"target": "es2022",
1111
"useDefineForClassFields": false,
12+
"esModuleInterop": true,
1213
"typeRoots": ["./node_modules/@types"]
1314
},
1415
"files": [

0 commit comments

Comments
 (0)