Skip to content
Draft
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
113 changes: 21 additions & 92 deletions packages/neo4j-driver/gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
const buffer = require('vinyl-buffer')
const gulp = require('gulp')
const uglify = require('gulp-uglify')
const jasmine = require('gulp-jasmine')
const watch = require('gulp-watch')
const batch = require('gulp-batch')
const replace = require('gulp-replace')
Expand All @@ -35,14 +34,8 @@ const semver = require('semver')
const sharedNeo4j = require('./test/internal/shared-neo4j').default
const stream = require('stream')
const ts = require('gulp-typescript')
const JasmineReporter = require('jasmine-spec-reporter').SpecReporter
const log = require('fancy-log')
const JasmineExec = require('jasmine')

/**
* Useful to investigate resource leaks in tests. Enable to see active sockets and file handles after the 'test' task.
*/
const enableActiveNodeHandlesLogging = false
const jest = require('jest')

const browserOutput = 'lib/browser'

Expand Down Expand Up @@ -113,32 +106,21 @@ gulp.task(
})
)

gulp.task(
'test-nodejs',
gulp.series('install-driver-into-sandbox', function () {
return gulp
.src(['./test/**/*.test.js', '!./test/**/browser/*.js'])
.pipe(
jasmine({
includeStackTrace: true,
reporter: newJasmineConsoleReporter()
})
)
.on('end', logActiveNodeHandles)
})
)
gulp.task('test-nodejs', () => {
return runJestTests()
})

gulp.task('test-nodejs-unit', () => {
return runJasmineTests('#unit*')
return runJestTests('#unit*')
})

gulp.task('test-nodejs-stub', () => {
return runJasmineTests('#stub*')
return runJestTests('#stub*')
})

gulp.task('test-nodejs-integration', async () => {
await sharedNeo4j.start()
return runJasmineTests('#integration*')
return runJestTests('#integration*')
})

gulp.task('watch', function () {
Expand All @@ -150,13 +132,6 @@ gulp.task('watch', function () {
)
})

gulp.task(
'watch-n-test',
gulp.series('test-nodejs', function () {
return gulp.watch(['src/**/*.js', 'test/**/*.js'], ['test-nodejs'])
})
)

/** Set the project version, controls package.json and version.js */
gulp.task('set', function () {
// example: gulp set --x 4.0.2
Expand Down Expand Up @@ -185,19 +160,7 @@ gulp.task('stop-neo4j', function (done) {
sharedNeo4j.stop().then(done).catch(error => done.fail(error))
})

gulp.task('run-stress-tests', function () {
return gulp
.src('test/**/stress.test.js')
.pipe(
jasmine({
includeStackTrace: true,
reporter: newJasmineConsoleReporter()
})
)
.on('end', logActiveNodeHandles)
})

gulp.task('run-stress-tests-without-jasmine', async function () {
gulp.task('run-stress-tests', async function () {
await sharedNeo4j.start()
const stresstest = require('./test/stress-test')
return stresstest()
Expand Down Expand Up @@ -232,56 +195,22 @@ gulp.task(

gulp.task('default', gulp.series('test'))

function logActiveNodeHandles () {
if (enableActiveNodeHandlesLogging) {
console.log(
'-- Active NodeJS handles START\n',
process._getActiveHandles(),
'\n-- Active NodeJS handles END'
)
function runJestTests (filterString) {
const options = {
passWithNoTests: true,
runInBand: true
}
if (filterString) {
options.testNamePattern = filterString
}
}

function newJasmineConsoleReporter () {
return new JasmineReporter({
colors: {
enabled: true
},
spec: {
displayDuration: true,
displayErrorMessages: true,
displayStacktrace: true,
displayFailed: true,
displaySuccessful: true,
displayPending: false
},
summary: {
displayFailed: true,
displayStacktrace: true,
displayErrorMessages: true
}
})
}

function runJasmineTests (filterString) {
return new Promise((resolve, reject) => {
const jasmine = new JasmineExec()
jasmine.loadConfigFile('./spec/support/jasmine.json')
jasmine.loadHelpers()
jasmine.loadSpecs()
jasmine.configureDefaultReporter({
print: () => {}
jest.runCLI(options, ['.']).then(testResults => {
if (testResults.results.success) {
resolve()
} else {
reject(new Error('Some tests failed, please review the log'))
}
})
jasmine.addReporter(newJasmineConsoleReporter())
jasmine.exitOnCompletion = false
jasmine.execute(null, filterString)
.then(result => {
if (result.overallStatus === 'passed') {
resolve()
} else {
reject(new Error('tests failed'))
}
})
})
}

Expand Down
10 changes: 7 additions & 3 deletions packages/neo4j-driver/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ export default {
'jsx',
'ts',
'tsx',
'node'
'node',
'd.ts'
],

globals: {
Expand Down Expand Up @@ -154,7 +155,9 @@ export default {

// The glob patterns Jest uses to detect test files
testMatch: [
'**/test/unit/?(*.)+(spec|test).[tj]s?(x)'
'**/test/?(*.)+(spec|test).[tj]s?(x)',
'**/test/internal/?(*.)+(spec|test).[tj]s?(x)',
'**/test/rx/?(*.)+(spec|test).[tj]s?(x)'
],

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
Expand Down Expand Up @@ -185,8 +188,9 @@ export default {
transformIgnorePatterns: [
'/node_modules/',
'\\.pnp\\.[^\\/]+$'
]
],

testTimeout: 15000
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,

Expand Down
4 changes: 2 additions & 2 deletions packages/neo4j-driver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
"test::unit": "gulp test-nodejs-unit && gulp run-ts-declaration-tests",
"test::browser": "jest -c jest.browser.config.ts --runInBand",
"test::integration": "gulp test-nodejs-integration",
"test::stress": "gulp run-stress-tests-without-jasmine",
"test::stress": "gulp run-stress-tests",
"build": "gulp all",
"start-neo4j": "gulp start-neo4j",
"stop-neo4j": "gulp stop-neo4j",
"run-stress-tests": "gulp run-stress-tests-without-jasmine",
"run-stress-tests": "gulp run-stress-tests",
"run-ts-declaration-tests": "gulp run-ts-declaration-tests",
"docs": "esdoc -c esdoc.json",
"versionRelease": "gulp set --x $VERSION && npm version $VERSION --no-git-tag-version",
Expand Down
68 changes: 18 additions & 50 deletions packages/neo4j-driver/test/bolt-v3.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('#integration Bolt V3 API', () => {
{ metadata }
)
const receivedMetadatas = result.records.map(r => r.get('metaData'))
expect(receivedMetadatas).toContain(metadata)
expect(receivedMetadatas).toContainEqual(metadata)
}, 20000)

it('should set transaction timeout for auto-commit transaction', async () => {
Expand Down Expand Up @@ -188,7 +188,7 @@ describe('#integration Bolt V3 API', () => {
// call listTransactions procedure that should list itself with the specified metadata
const result = await tx.run('CALL dbms.listTransactions()')
const receivedMetadatas = result.records.map(r => r.get('metaData'))
expect(receivedMetadatas).toContain(metadata)
expect(receivedMetadatas).toContainEqual(metadata)

await tx.commit()
}, 20000)
Expand Down Expand Up @@ -468,7 +468,7 @@ describe('#integration Bolt V3 API', () => {
tx.run('CALL dbms.listTransactions()')
)
const receivedMetadatas = result.records.map(r => r.get('metaData'))
expect(receivedMetadatas).toContain(metadata)
expect(receivedMetadatas).toContainEqual(metadata)
}

async function testAutoCommitTransactionConfigWhenBoltV3NotSupported (
Expand All @@ -478,19 +478,9 @@ describe('#integration Bolt V3 API', () => {
return
}

if (typeof jasmine === 'undefined') {
return
}

await expectAsync(
session.run('RETURN $x', { x: 42 }, txConfig)
).toBeRejectedWith(
jasmine.objectContaining({
message: jasmine.stringMatching(
/Driver is connected to the database that does not support transaction configuration/
)
})
)
expect(
(await session.run('RETURN $x', { x: 42 }, txConfig)).message
).toContain('Driver is connected to the database that does not support transaction configuration')
}

async function testTransactionFunctionConfigWhenBoltV3NotSupported (
Expand All @@ -501,23 +491,15 @@ describe('#integration Bolt V3 API', () => {
return
}

if (typeof jasmine === 'undefined') {
return
}

const txFunctionWithMetadata = work =>
read
? session.executeRead(work, txConfig)
: session.executeWrite(work, txConfig)

await expectAsync(
txFunctionWithMetadata(tx => tx.run('RETURN 42'))
).toBeRejectedWith(
jasmine.objectContaining({
message: jasmine.stringMatching(
/Driver is connected to the database that does not support transaction configuration/
)
})
expect(
await txFunctionWithMetadata(tx => tx.run('RETURN 42')).message
).toContain(
'Driver is connected to the database that does not support transaction configuration'
)
}

Expand All @@ -528,19 +510,12 @@ describe('#integration Bolt V3 API', () => {
return
}

if (typeof jasmine === 'undefined') {
return
}

const tx = session.beginTransaction(txConfig)

await expectAsync(tx.run('RETURN 42')).toBeRejectedWith(
jasmine.objectContaining({
message: jasmine.stringMatching(
/Driver is connected to the database that does not support transaction configuration/
)
})
)
expect((await tx.run('RETURN 42')).message)
.toContain(
'Driver is connected to the database that does not support transaction configuration'
)
}

async function testCloseExplicitTransactionWithConfigWhenBoltV3NotSupported (
Expand All @@ -551,19 +526,12 @@ describe('#integration Bolt V3 API', () => {
return
}

if (typeof jasmine === 'undefined') {
return
}

const tx = session.beginTransaction(txConfig)

await expectAsync(commit ? tx.commit() : tx.rollback()).toBeRejectedWith(
jasmine.objectContaining({
message: jasmine.stringMatching(
/Driver is connected to the database that does not support transaction configuration/
)
})
)
expect((await (commit ? tx.commit() : tx.rollback())).message)
.toContain(
'Driver is connected to the database that does not support transaction configuration'
)
}

function databaseSupportsBoltV3 () {
Expand Down
48 changes: 0 additions & 48 deletions packages/neo4j-driver/test/browser/jasmine-runner.html

This file was deleted.

Loading