Skip to content

Commit a94467b

Browse files
Neo4j
1 parent 392eb50 commit a94467b

File tree

2 files changed

+35
-17
lines changed

2 files changed

+35
-17
lines changed

docs/modules/neo4j.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# Neo4j Module
2-
3-
[Neo4j](https://neo4j.com/) is a highly scalable, robust native graph database.
1+
# Neo4j
42

53
## Install
64

@@ -10,18 +8,34 @@ npm install @testcontainers/neo4j --save-dev
108

119
## Examples
1210

11+
These examples use the following libraries:
12+
13+
- [neo4j-driver](https://www.npmjs.com/package/neo4j-driver)
14+
15+
npm install neo4j-driver
16+
17+
Choose an image from the [container registry](https://hub.docker.com/_/neo4j) and substitute `IMAGE`.
18+
19+
### Create a node
20+
1321
<!--codeinclude-->
14-
[Connect and create a node:](../../packages/modules/neo4j/src/neo4j-container.test.ts) inside_block:createNode
22+
[](../../packages/modules/neo4j/src/neo4j-container.test.ts) inside_block:createNode
1523
<!--/codeinclude-->
1624

25+
### With credentials
26+
1727
<!--codeinclude-->
18-
[Set password:](../../packages/modules/neo4j/src/neo4j-container.test.ts) inside_block:setPassword
28+
[](../../packages/modules/neo4j/src/neo4j-container.test.ts) inside_block:setPassword
1929
<!--/codeinclude-->
2030

31+
### With APOC
32+
2133
<!--codeinclude-->
22-
[Configure APOC:](../../packages/modules/neo4j/src/neo4j-container.test.ts) inside_block:apoc
34+
[](../../packages/modules/neo4j/src/neo4j-container.test.ts) inside_block:apoc
2335
<!--/codeinclude-->
2436

37+
### With plugins
38+
2539
<!--codeinclude-->
26-
[Configure other supported plugins:](../../packages/modules/neo4j/src/neo4j-container.test.ts) inside_block:pluginsList
40+
[](../../packages/modules/neo4j/src/neo4j-container.test.ts) inside_block:pluginsList
2741
<!--/codeinclude-->

packages/modules/neo4j/src/neo4j-container.test.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ import { Neo4jContainer, Neo4jPlugin } from "./neo4j-container";
55
const IMAGE = getImage(__dirname);
66

77
describe("Neo4jContainer", { timeout: 180_000 }, () => {
8-
// createNode {
98
it("should create a person node", async () => {
9+
// createNode {
1010
await using container = await new Neo4jContainer(IMAGE).start();
11+
1112
const driver = neo4j.driver(
1213
container.getBoltUri(),
1314
neo4j.auth.basic(container.getUsername(), container.getPassword())
1415
);
15-
1616
const session = driver.session();
17+
1718
const personName = "Chris";
1819
const result = await session.run("CREATE (a:Person {name: $name}) RETURN a", { name: personName });
1920
const singleRecord = result.records[0];
@@ -22,8 +23,8 @@ describe("Neo4jContainer", { timeout: 180_000 }, () => {
2223

2324
await session.close();
2425
await driver.close();
26+
// }
2527
});
26-
// }
2728

2829
// v5DefaultPassword {
2930
it("should connect to neo4j:v5 with default password", async () => {
@@ -45,13 +46,15 @@ describe("Neo4jContainer", { timeout: 180_000 }, () => {
4546
});
4647
// }
4748

48-
// setPassword {
4949
it("should connect with custom password", async () => {
50+
// setPassword {
5051
await using container = await new Neo4jContainer(IMAGE).withPassword("xyz1234@!").start();
52+
5153
const driver = neo4j.driver(
5254
container.getBoltUri(),
5355
neo4j.auth.basic(container.getUsername(), container.getPassword())
5456
);
57+
// }
5558

5659
const session = driver.session();
5760
const personName = "Chris";
@@ -63,32 +66,33 @@ describe("Neo4jContainer", { timeout: 180_000 }, () => {
6366
await session.close();
6467
await driver.close();
6568
});
66-
// }
6769

68-
// apoc {
6970
it("should have APOC plugin installed", async () => {
71+
// apoc {
7072
await using container = await new Neo4jContainer(IMAGE).withApoc().withStartupTimeout(120_000).start();
73+
7174
const driver = neo4j.driver(
7275
container.getBoltUri(),
7376
neo4j.auth.basic(container.getUsername(), container.getPassword())
7477
);
75-
7678
const session = driver.session();
79+
7780
const result = await session.run("CALL apoc.help('text')");
7881
const singleRecord = result.records[0];
7982
expect(singleRecord.length).toBeGreaterThan(0);
83+
// }
8084

8185
await session.close();
8286
await driver.close();
8387
});
84-
// }
8588

86-
// pluginsList {
8789
it("should work with plugin list", async () => {
90+
// pluginsList {
8891
await using container = await new Neo4jContainer("neo4j:5.26.5")
8992
.withPlugins([Neo4jPlugin.APOC_EXTENDED, Neo4jPlugin.GRAPH_DATA_SCIENCE])
9093
.withStartupTimeout(120_000)
9194
.start();
95+
9296
const driver = neo4j.driver(
9397
container.getBoltUri(),
9498
neo4j.auth.basic(container.getUsername(), container.getPassword())
@@ -109,6 +113,6 @@ describe("Neo4jContainer", { timeout: 180_000 }, () => {
109113

110114
await session.close();
111115
await driver.close();
116+
// }
112117
});
113-
// }
114118
});

0 commit comments

Comments
 (0)