Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ jobs:

- name: Run unit tests
run: npm run test:unit

- name: Test ES module compliance
run: npm run test:esm
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
"scripts": {
"build": "tsc",
"lint": "eslint src",
"test": "vitest run",
"test": "npm run build && vitest run",
"test:unit": "vitest run tests/unit",
"test:e2e": "vitest run tests/e2e",
"test:esm": "npm run build && node test-esm-strict.mjs",
"test:watch": "vitest",
"test:coverage": "vitest run --coverage",
"prepublishOnly": "npm run build"
Expand Down
16 changes: 16 additions & 0 deletions test-esm-strict.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Strict ES module test - runs with Node.js directly
* This will fail if imports don't have proper .js extensions
*/
import { createClient } from './dist/index.js';

console.log('✅ ES module import successful');
console.log('createClient:', typeof createClient);

const client = createClient({
apiKey: 'test-key',
baseURL: 'https://api.test.com'
});

console.log('✅ Client creation successful');
process.exit(0);
21 changes: 21 additions & 0 deletions tests/esm-compliance.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Test to verify ES module compliance by importing the built SDK
* This test runs against the compiled output to catch import issues
*/
import { createClient } from '../dist/index.js';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this really catch stuff? aren't we good with test:esm? might be nicer DX to not have to run build to run the unit tests

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified it would have failed with the issue that I fixed in #33
if you have a better way to prevent sdk breaking prod let me know and I'll change

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can move to "e2e" to be semantically correct

import { describe, it, expect } from 'vitest';

describe('ES Module Compliance', () => {
it('should import the SDK successfully from built dist', () => {
expect(createClient).toBeDefined();
expect(typeof createClient).toBe('function');
});

it('should create a client instance', () => {
const client = createClient({
apiKey: 'test-key',
baseURL: 'https://api.test.com'
});
expect(client).toBeDefined();
});
});
Loading