Skip to content

Commit e5db825

Browse files
authored
Merge pull request #3 from siarheidudko/copilot/update-dependencies-and-fix-tests
Update dependencies, bump patch, and harden Stripe test bootstrap
2 parents 5afa614 + 79ea4d9 commit e5db825

File tree

4 files changed

+47
-22
lines changed

4 files changed

+47
-22
lines changed

package-lock.json

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

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sergdudko/stripe-js",
3-
"version": "2.0.63",
3+
"version": "2.0.64",
44
"description": "Supercharge Your Stripe Integration with Enhanced Methods for stripe-js: Take Full Control of Customer Card Management Right from Your Frontend! Elevate Your Payment Processing Capabilities with Ease and Efficiency.",
55
"type": "module",
66
"main": "./dist/cjs/index.js",
@@ -33,7 +33,9 @@
3333
"postbuild:cjs": "echo '{\"type\":\"commonjs\"}' > ./dist/cjs/package.json",
3434
"postbuild:esm": "echo '{\"type\":\"module\"}' > ./dist/esm/package.json",
3535
"build": "npm run build:cjs && npm run build:esm",
36-
"test": "./node_modules/.bin/nyc node --test --import tsx ./test/*.test.ts",
36+
"pretest": "npm run build",
37+
"test": "npm run test:only",
38+
"test:only": "./node_modules/.bin/nyc node --test --import tsx ./test/*.test.ts",
3739
"test:local": "./node_modules/.bin/nyc node --env-file=.env.local --test --import tsx ./test/*.test.ts",
3840
"update": "eval \"$(node -e 'const t = require(`./package.json`);const ignore = require(`./ignoreUpdatesModules.json`);console.log(`npm i ${(Object.keys(t.dependencies||{}).filter((e)=>ignore.base.indexOf(e) === -1).map((e)=>(`${e}@latest`)).join(` `))} --save&&npm i ${(Object.keys(t.devDependencies||{}).filter((e)=>ignore.dev.indexOf(e) === -1).map((e)=>(`${e}@latest`)).join(` `))} --save-dev`);')\""
3941
},
@@ -88,7 +90,7 @@
8890
"homepage": "https://github.com/siarheidudko/stripe-js#readme",
8991
"devDependencies": {
9092
"@eslint/js": "^9.39.2",
91-
"@types/node": "^25.2.1",
93+
"@types/node": "^25.2.2",
9294
"eslint": "^9.39.2",
9395
"jsdom": "^28.0.0",
9496
"jsdom-global": "^3.0.2",

test/loadStripe.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@ import { Stripe as StripeAdmin } from "stripe";
44
import {
55
stripeAdminSDK,
66
stripeApiVersion,
7+
hasStripeCredentials,
78
stripePublicKey,
89
stripeExtensionJS,
910
cleanDom,
1011
} from "./utils/loader";
1112

1213
const lib = stripeExtensionJS;
1314

14-
describe("Checking the initializing function:", function () {
15+
describe(
16+
"Checking the initializing function:",
17+
{ skip: !hasStripeCredentials },
18+
function () {
1519
/**
1620
* Stripe Client SDK (sergdudko/stripe-js)
1721
*/
@@ -523,4 +527,5 @@ describe("Checking the initializing function:", function () {
523527
}
524528
return;
525529
});
526-
});
530+
}
531+
);

test/utils/loader.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import stripe from "stripe";
1+
import Stripe from "stripe";
22
import { EventEmitter } from "events";
33
import createJSDom from "jsdom-global";
44
import { readFileSync } from "fs";
@@ -85,28 +85,35 @@ const createDom = () => {
8585
);
8686
};
8787
};
88-
createDom();
89-
9088
/**
9189
* Stripe public key (see: https://dashboard.stripe.com/test/apikeys)
9290
*/
93-
const stripePublicKey = process.env.STRIPE_TEST_PK!;
91+
const stripePublicKey = process.env.STRIPE_TEST_PK;
9492
/**
9593
* Stripe secret key (see: https://dashboard.stripe.com/test/apikeys)
9694
*/
97-
const stripeSecretKey = process.env.STRIPE_TEST_SK!;
95+
const stripeSecretKey = process.env.STRIPE_TEST_SK;
9896

99-
/**
100-
* Stripe Admin SDK (server)
101-
*/
102-
const stripeAdminSDK = new stripe(stripeSecretKey, {
103-
apiVersion: stripeApiVersion as any,
104-
});
97+
// stripeAdminSDK is only available when Stripe credentials are set; check hasStripeCredentials first.
98+
let stripeAdminSDK: Stripe | undefined;
99+
let hasStripeCredentials = false;
100+
101+
if (!!stripePublicKey && !!stripeSecretKey) {
102+
/**
103+
* Stripe Admin SDK (server)
104+
*/
105+
stripeAdminSDK = new Stripe(stripeSecretKey, {
106+
apiVersion: stripeApiVersion as Stripe.LatestApiVersion,
107+
});
108+
hasStripeCredentials = true;
109+
createDom();
110+
}
105111

106112
export {
107113
stripeExtensionJS,
108114
stripeAdminSDK,
109115
stripeApiVersion,
116+
hasStripeCredentials,
110117
stripePublicKey,
111118
stripeSecretKey,
112119
createDom,

0 commit comments

Comments
 (0)