Skip to content

Commit bb5687e

Browse files
authored
Merge pull request #1210 from bigmontz/fix-npm-test
Fix `npm test` when running test containers
2 parents 7ffa4af + b2ca1d4 commit bb5687e

File tree

1 file changed

+54
-35
lines changed

1 file changed

+54
-35
lines changed

packages/neo4j-driver-deno/test/neo4j.test.ts

Lines changed: 54 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -27,58 +27,77 @@ const scheme = env.TEST_NEO4J_SCHEME || 'bolt'
2727
const boltPort = env.TEST_NEO4J_BOLT_PORT || 7687
2828
const uri = `${scheme}://${hostname}:${boltPort}`
2929
const authToken = neo4j.auth.basic(username, password)
30+
const testContainersDisabled = env.TEST_CONTAINERS_DISABLED !== undefined
31+
? env.TEST_CONTAINERS_DISABLED.toUpperCase() === 'TRUE'
32+
: false
3033

3134
// Deno will fail with resource leaks
32-
Deno.test('neo4j.driver should be able to use explicity resource management', async () => {
33-
await using driver = neo4j.driver(uri, authToken)
35+
Deno.test({
36+
name: 'neo4j.driver should be able to use explicity resource management',
37+
ignore: !testContainersDisabled,
38+
async fn() {
39+
await using driver = neo4j.driver(uri, authToken)
3440

35-
await driver.executeQuery('RETURN 1')
36-
})
37-
38-
// Deno will fail with resource leaks
39-
Deno.test('driver.session should be able to use explicity resource management', async () => {
40-
await using driver = neo4j.driver(uri, authToken)
41-
await using session = driver.session()
42-
43-
await session.executeRead(tx => "RETURN 1")
41+
await driver.executeQuery('RETURN 1')
42+
}
4443
})
4544

46-
4745
// Deno will fail with resource leaks
48-
Deno.test('session.beginTransaction should rollback the transaction if not committed', async () => {
49-
await using driver = neo4j.driver(uri, authToken)
50-
await using session = driver.session()
51-
const name = "Must Be Conor"
46+
Deno.test({
47+
name: 'driver.session should be able to use explicity resource management',
48+
ignore: !testContainersDisabled,
49+
async fn() {
50+
await using driver = neo4j.driver(uri, authToken)
51+
await using session = driver.session()
5252

53+
await session.executeRead(tx => "RETURN 1")
5354

54-
{
55-
await using tx = session.beginTransaction()
56-
await tx.run('CREATE (p:Person { name:$name }) RETURN p', { name }).summary()
5755
}
58-
59-
const { records } = await driver.executeQuery('MATCH (p:Person { name:$name }) RETURN p', { name })
60-
assertEquals(records.length, 0)
6156
})
6257

63-
6458
// Deno will fail with resource leaks
65-
Deno.test('session.beginTransaction should noop if resource committed', async () => {
66-
await using driver = neo4j.driver(uri, authToken)
67-
const name = "Must Be Conor"
68-
69-
try {
59+
Deno.test({
60+
name: 'session.beginTransaction should rollback the transaction if not committed',
61+
ignore: !testContainersDisabled,
62+
async fn() {
63+
await using driver = neo4j.driver(uri, authToken)
7064
await using session = driver.session()
71-
65+
const name = "Must Be Conor"
66+
7267
{
7368
await using tx = session.beginTransaction()
7469
await tx.run('CREATE (p:Person { name:$name }) RETURN p', { name }).summary()
75-
await tx.commit()
7670
}
77-
71+
7872
const { records } = await driver.executeQuery('MATCH (p:Person { name:$name }) RETURN p', { name })
79-
assertEquals(records.length, 1)
80-
} finally {
81-
// cleaning up
82-
await driver.executeQuery('MATCH (p:Person { name:$name }) DELETE(p)', { name })
73+
assertEquals(records.length, 0)
74+
}
75+
})
76+
77+
78+
// Deno will fail with resource leaks
79+
Deno.test({
80+
name: 'session.beginTransaction should noop if resource committed',
81+
ignore: !testContainersDisabled,
82+
async fn() {
83+
await using driver = neo4j.driver(uri, authToken)
84+
const name = "Must Be Conor"
85+
86+
try {
87+
await using session = driver.session()
88+
89+
{
90+
await using tx = session.beginTransaction()
91+
await tx.run('CREATE (p:Person { name:$name }) RETURN p', { name }).summary()
92+
await tx.commit()
93+
}
94+
95+
const { records } = await driver.executeQuery('MATCH (p:Person { name:$name }) RETURN p', { name })
96+
assertEquals(records.length, 1)
97+
} finally {
98+
// cleaning up
99+
await driver.executeQuery('MATCH (p:Person { name:$name }) DELETE(p)', { name })
100+
}
101+
83102
}
84103
})

0 commit comments

Comments
 (0)