Skip to content

Commit

Permalink
Skip the CommonJS variants if using GraphQL 17
Browse files Browse the repository at this point in the history
GraphQL 17 will only be bundled in ESM mode
  • Loading branch information
eirikur-nc committed Nov 8, 2024
1 parent 6e4d751 commit c4a1bf9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/load/tests/use-custom-loader.node.mjs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import assert from 'node:assert';
import { describe, it } from 'node:test';
import { versionInfo as graphqlVersionInfo } from 'graphql';
import { useCustomLoader, useCustomLoaderSync } from '../src/utils/custom-loader.ts';

describe('useCustomLoader', () => {
it('can load a custom cjs loader from a file path', async () => {
const skipCjsTests = graphqlVersionInfo.major >= 17;

it('can load a custom cjs loader from a file path', { skip: skipCjsTests }, async () => {
const loader = await useCustomLoader(`./custom-loader.cjs`, import.meta.dirname);
const result = await loader('some-name', { customLoaderContext: {} });
assert.strictEqual(result, 'I like turtles');
});

it('can load a custom cjs loader synchronously', async () => {
it('can load a custom cjs loader synchronously', { skip: skipCjsTests }, async () => {
const loader = useCustomLoaderSync(`./custom-loader.cjs`, import.meta.dirname);
const result = await loader('some-name', { customLoaderContext: {} });
assert.strictEqual(result, 'I like turtles');
Expand Down

0 comments on commit c4a1bf9

Please sign in to comment.