Skip to content

Commit 65bc70d

Browse files
committed
refactor: Refactor integration tests to use assert and remove comments/logs
1 parent 4da5e9b commit 65bc70d

File tree

19 files changed

+91
-229
lines changed

19 files changed

+91
-229
lines changed

integrationTests/dev-bun/test.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import assert from 'assert';
12
import { isObjectType } from 'graphql';
23

3-
// Create a fake GraphQLObjectType to test instanceof behavior
44
class FakeGraphQLObjectType {
55
constructor() {
66
this.name = 'Fake';
@@ -10,17 +10,11 @@ class FakeGraphQLObjectType {
1010
const fakeInstance = new FakeGraphQLObjectType();
1111

1212
try {
13-
const result = isObjectType(fakeInstance);
14-
15-
// In development mode, this should throw an error about multiple GraphQL modules
16-
// If we get here without an error, development mode is not working
17-
console.error('✗ Development mode test failed - expected error was not thrown');
18-
process.exit(1);
13+
isObjectType(fakeInstance);
14+
assert.fail('Expected isObjectType to throw an error in Bun development mode.');
1915
} catch (error) {
20-
if (error.message.includes('multiple') || error.message.includes('GraphQL')) {
21-
console.log('✓ Bun development mode integration test passed');
22-
} else {
23-
console.error('✗ Development mode test failed - unexpected error:', error.message);
24-
process.exit(1);
25-
}
16+
assert.ok(
17+
error.message.includes('multiple') || error.message.includes('GraphQL'),
18+
`Expected error message to include 'multiple' or 'GraphQL', but got: "${error.message}"`
19+
);
2620
}

integrationTests/dev-deno/test.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import assert from 'assert';
12
import { isObjectType } from 'graphql';
23

3-
// Create a fake GraphQLObjectType to test instanceof behavior
44
class FakeGraphQLObjectType {
55
constructor() {
66
this.name = 'Fake';
@@ -10,17 +10,11 @@ class FakeGraphQLObjectType {
1010
const fakeInstance = new FakeGraphQLObjectType();
1111

1212
try {
13-
const result = isObjectType(fakeInstance);
14-
15-
// In development mode, this should throw an error about multiple GraphQL modules
16-
// If we get here without an error, development mode is not working
17-
console.error('✗ Development mode test failed - expected error was not thrown');
18-
process.exit(1);
13+
isObjectType(fakeInstance);
14+
assert.fail('Expected isObjectType to throw an error in Deno development mode.');
1915
} catch (error) {
20-
if (error.message.includes('multiple') || error.message.includes('GraphQL')) {
21-
console.log('✓ Deno development mode integration test passed');
22-
} else {
23-
console.error('✗ Development mode test failed - unexpected error:', error.message);
24-
process.exit(1);
25-
}
16+
assert.ok(
17+
error.message.includes('multiple') || error.message.includes('GraphQL'),
18+
`Expected error message to include 'multiple' or 'GraphQL', but got: "${error.message}"`
19+
);
2620
}
Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import assert from 'assert';
12
import { isObjectType } from 'graphql';
23

3-
// Create a fake GraphQLObjectType to test instanceof behavior
44
class FakeGraphQLObjectType {
55
constructor() {
66
this.name = 'Fake';
@@ -10,17 +10,11 @@ class FakeGraphQLObjectType {
1010
const fakeInstance = new FakeGraphQLObjectType();
1111

1212
try {
13-
const result = isObjectType(fakeInstance);
14-
15-
// In development mode, this should throw an error about multiple GraphQL modules
16-
// If we get here without an error, development mode is not working
17-
console.error('✗ Development mode test failed - expected error was not thrown');
18-
process.exit(1);
13+
isObjectType(fakeInstance);
14+
assert.fail('Expected isObjectType to throw an error in esbuild development mode.');
1915
} catch (error) {
20-
if (error.message.includes('multiple') || error.message.includes('GraphQL')) {
21-
console.log('✓ esbuild development mode integration test passed');
22-
} else {
23-
console.error('✗ Development mode test failed - unexpected error:', error.message);
24-
process.exit(1);
25-
}
16+
assert.ok(
17+
error.message.includes('multiple') || error.message.includes('GraphQL'),
18+
`Expected error message to include 'multiple' or 'GraphQL', but got: "${error.message}"`
19+
);
2620
}

integrationTests/dev-nextjs/test.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import assert from 'assert';
12
import { isObjectType } from 'graphql';
23

3-
// Create a fake GraphQLObjectType to test instanceof behavior
44
class FakeGraphQLObjectType {
55
constructor() {
66
this.name = 'Fake';
@@ -10,17 +10,11 @@ class FakeGraphQLObjectType {
1010
const fakeInstance = new FakeGraphQLObjectType();
1111

1212
try {
13-
const result = isObjectType(fakeInstance);
14-
15-
// In development mode, this should throw an error about multiple GraphQL modules
16-
// If we get here without an error, development mode is not working
17-
console.error('✗ Development mode test failed - expected error was not thrown');
18-
process.exit(1);
13+
isObjectType(fakeInstance);
14+
assert.fail('Expected isObjectType to throw an error in Next.js development mode.');
1915
} catch (error) {
20-
if (error.message.includes('multiple') || error.message.includes('GraphQL')) {
21-
console.log('✓ Next.js development mode integration test passed');
22-
} else {
23-
console.error('✗ Development mode test failed - unexpected error:', error.message);
24-
process.exit(1);
25-
}
16+
assert.ok(
17+
error.message.includes('multiple') || error.message.includes('GraphQL'),
18+
`Expected error message to include 'multiple' or 'GraphQL', but got: "${error.message}"`
19+
);
2620
}
Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import assert from 'assert';
12
import { isObjectType } from 'graphql';
23

3-
// Create a fake GraphQLObjectType to test instanceof behavior
44
class FakeGraphQLObjectType {
55
constructor() {
66
this.name = 'Fake';
@@ -10,17 +10,11 @@ class FakeGraphQLObjectType {
1010
const fakeInstance = new FakeGraphQLObjectType();
1111

1212
try {
13-
const result = isObjectType(fakeInstance);
14-
15-
// In development mode, this should throw an error about multiple GraphQL modules
16-
// If we get here without an error, development mode is not working
17-
console.error('✗ Development mode test failed - expected error was not thrown');
18-
process.exit(1);
13+
isObjectType(fakeInstance);
14+
assert.fail('Expected isObjectType to throw an error in Node.js explicit development mode.');
1915
} catch (error) {
20-
if (error.message.includes('multiple') || error.message.includes('GraphQL')) {
21-
console.log('✓ Node.js explicit development mode integration test passed');
22-
} else {
23-
console.error('✗ Development mode test failed - unexpected error:', error.message);
24-
process.exit(1);
25-
}
16+
assert.ok(
17+
error.message.includes('multiple') || error.message.includes('GraphQL'),
18+
`Expected error message to include 'multiple' or 'GraphQL', but got: "${error.message}"`
19+
);
2620
}
Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import assert from 'assert';
12
import { isObjectType } from 'graphql';
23

3-
// Create a fake GraphQLObjectType to test instanceof behavior
44
class FakeGraphQLObjectType {
55
constructor() {
66
this.name = 'Fake';
@@ -10,17 +10,11 @@ class FakeGraphQLObjectType {
1010
const fakeInstance = new FakeGraphQLObjectType();
1111

1212
try {
13-
const result = isObjectType(fakeInstance);
14-
15-
// In development mode, this should throw an error about multiple GraphQL modules
16-
// If we get here without an error, development mode is not working
17-
console.error('✗ Development mode test failed - expected error was not thrown');
18-
process.exit(1);
13+
isObjectType(fakeInstance);
14+
assert.fail('Expected isObjectType to throw an error in Node.js implicit development mode.');
1915
} catch (error) {
20-
if (error.message.includes('multiple') || error.message.includes('GraphQL')) {
21-
console.log('✓ Node.js development mode integration test passed');
22-
} else {
23-
console.error('✗ Development mode test failed - unexpected error:', error.message);
24-
process.exit(1);
25-
}
16+
assert.ok(
17+
error.message.includes('multiple') || error.message.includes('GraphQL'),
18+
`Expected error message to include 'multiple' or 'GraphQL', but got: "${error.message}"`
19+
);
2620
}
Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import assert from 'assert';
12
import { isObjectType } from 'graphql';
23

3-
// Create a fake GraphQLObjectType to test instanceof behavior
44
class FakeGraphQLObjectType {
55
constructor() {
66
this.name = 'Fake';
@@ -10,17 +10,11 @@ class FakeGraphQLObjectType {
1010
const fakeInstance = new FakeGraphQLObjectType();
1111

1212
try {
13-
const result = isObjectType(fakeInstance);
14-
15-
// In development mode, this should throw an error about multiple GraphQL modules
16-
// If we get here without an error, development mode is not working
17-
console.error('✗ Development mode test failed - expected error was not thrown');
18-
process.exit(1);
13+
isObjectType(fakeInstance);
14+
assert.fail('Expected isObjectType to throw an error in Rollup development mode.');
1915
} catch (error) {
20-
if (error.message.includes('multiple') || error.message.includes('GraphQL')) {
21-
console.log('✓ Rollup development mode integration test passed');
22-
} else {
23-
console.error('✗ Development mode test failed - unexpected error:', error.message);
24-
process.exit(1);
25-
}
16+
assert.ok(
17+
error.message.includes('multiple') || error.message.includes('GraphQL'),
18+
`Expected error message to include 'multiple' or 'GraphQL', but got: "${error.message}"`
19+
);
2620
}

integrationTests/dev-swc/src/index.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import assert from 'assert';
12
import { isObjectType } from 'graphql';
23

3-
// Create a fake GraphQLObjectType to test instanceof behavior
44
class FakeGraphQLObjectType {
55
constructor() {
66
this.name = 'Fake';
@@ -10,17 +10,11 @@ class FakeGraphQLObjectType {
1010
const fakeInstance = new FakeGraphQLObjectType();
1111

1212
try {
13-
const result = isObjectType(fakeInstance);
14-
15-
// In development mode, this should throw an error about multiple GraphQL modules
16-
// If we get here without an error, development mode is not working
17-
console.error('✗ Development mode test failed - expected error was not thrown');
18-
process.exit(1);
13+
isObjectType(fakeInstance);
14+
assert.fail('Expected isObjectType to throw an error in SWC development mode.');
1915
} catch (error) {
20-
if (error.message.includes('multiple') || error.message.includes('GraphQL')) {
21-
console.log('✓ SWC development mode integration test passed');
22-
} else {
23-
console.error('✗ Development mode test failed - unexpected error:', error.message);
24-
process.exit(1);
25-
}
16+
assert.ok(
17+
error.message.includes('multiple') || error.message.includes('GraphQL'),
18+
`Expected error message to include 'multiple' or 'GraphQL', but got: "${error.message}"`
19+
);
2620
}
Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import assert from 'assert';
12
import { isObjectType } from 'graphql';
23

3-
// Create a fake GraphQLObjectType to test instanceof behavior
44
class FakeGraphQLObjectType {
55
constructor() {
66
this.name = 'Fake';
@@ -10,17 +10,11 @@ class FakeGraphQLObjectType {
1010
const fakeInstance = new FakeGraphQLObjectType();
1111

1212
try {
13-
const result = isObjectType(fakeInstance);
14-
15-
// In development mode, this should throw an error about multiple GraphQL modules
16-
// If we get here without an error, development mode is not working
17-
console.error('✗ Development mode test failed - expected error was not thrown');
18-
process.exit(1);
13+
isObjectType(fakeInstance);
14+
assert.fail('Expected isObjectType to throw an error in Vite development mode.');
1915
} catch (error) {
20-
if (error.message.includes('multiple') || error.message.includes('GraphQL')) {
21-
console.log('✓ Vite development mode integration test passed');
22-
} else {
23-
console.error('✗ Development mode test failed - unexpected error:', error.message);
24-
process.exit(1);
25-
}
16+
assert.ok(
17+
error.message.includes('multiple') || error.message.includes('GraphQL'),
18+
`Expected error message to include 'multiple' or 'GraphQL', but got: "${error.message}"`
19+
);
2620
}
Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import assert from 'assert';
12
import { isObjectType } from 'graphql';
23

3-
// Create a fake GraphQLObjectType to test instanceof behavior
44
class FakeGraphQLObjectType {
55
constructor() {
66
this.name = 'Fake';
@@ -10,17 +10,11 @@ class FakeGraphQLObjectType {
1010
const fakeInstance = new FakeGraphQLObjectType();
1111

1212
try {
13-
const result = isObjectType(fakeInstance);
14-
15-
// In development mode, this should throw an error about multiple GraphQL modules
16-
// If we get here without an error, development mode is not working
17-
console.error('✗ Development mode test failed - expected error was not thrown');
18-
process.exit(1);
13+
isObjectType(fakeInstance);
14+
assert.fail('Expected isObjectType to throw an error in Webpack development mode.');
1915
} catch (error) {
20-
if (error.message.includes('multiple') || error.message.includes('GraphQL')) {
21-
console.log('✓ Webpack development mode integration test passed');
22-
} else {
23-
console.error('✗ Development mode test failed - unexpected error:', error.message);
24-
process.exit(1);
25-
}
16+
assert.ok(
17+
error.message.includes('multiple') || error.message.includes('GraphQL'),
18+
`Expected error message to include 'multiple' or 'GraphQL', but got: "${error.message}"`
19+
);
2620
}

integrationTests/prod-bun/test.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,12 @@
1+
import assert from 'assert';
12
import { isObjectType } from 'graphql';
23

3-
// Create a fake GraphQLObjectType to test instanceof behavior
44
class FakeGraphQLObjectType {
55
constructor() {
66
this.name = 'Fake';
77
}
88
}
99

1010
const fakeInstance = new FakeGraphQLObjectType();
11-
12-
try {
13-
const result = isObjectType(fakeInstance);
14-
15-
// In production mode, this should return false without throwing
16-
if (result === false) {
17-
console.log('✓ Bun production mode integration test passed');
18-
} else {
19-
console.error('✗ Production mode test failed - expected false, got:', result);
20-
process.exit(1);
21-
}
22-
} catch (error) {
23-
console.error('✗ Production mode test failed - unexpected error:', error.message);
24-
process.exit(1);
25-
}
11+
const result = isObjectType(fakeInstance);
12+
assert.strictEqual(result, false, 'isObjectType should return false in Bun production mode.');

integrationTests/prod-deno/test.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,12 @@
1+
import assert from 'assert';
12
import { isObjectType } from 'graphql';
23

3-
// Create a fake GraphQLObjectType to test instanceof behavior
44
class FakeGraphQLObjectType {
55
constructor() {
66
this.name = 'Fake';
77
}
88
}
99

1010
const fakeInstance = new FakeGraphQLObjectType();
11-
12-
try {
13-
const result = isObjectType(fakeInstance);
14-
15-
// In production mode, this should return false without throwing
16-
if (result === false) {
17-
console.log('✓ Deno production mode integration test passed');
18-
} else {
19-
console.error('✗ Production mode test failed - expected false, got:', result);
20-
process.exit(1);
21-
}
22-
} catch (error) {
23-
console.error('✗ Production mode test failed - unexpected error:', error.message);
24-
process.exit(1);
25-
}
11+
const result = isObjectType(fakeInstance);
12+
assert.strictEqual(result, false, 'isObjectType should return false in Deno production mode.');

0 commit comments

Comments
 (0)