mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Add a global test setup
Configure SandboxedModule with common options, including some globals that are required in Node 12.
This commit is contained in:
parent
96399470c3
commit
c68e1a2dfe
4 changed files with 14 additions and 5 deletions
3
services/contacts/.mocharc.json
Normal file
3
services/contacts/.mocharc.json
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"require": "test/setup.js"
|
||||||
|
}
|
9
services/contacts/test/setup.js
Normal file
9
services/contacts/test/setup.js
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
const SandboxedModule = require('sandboxed-module')
|
||||||
|
|
||||||
|
SandboxedModule.configure({
|
||||||
|
requires: {
|
||||||
|
'logger-sharelatex': { log() {} },
|
||||||
|
'@overleaf/metrics': { timeAsyncMethod() {} }
|
||||||
|
},
|
||||||
|
globals: { Buffer, console, process }
|
||||||
|
})
|
|
@ -26,9 +26,7 @@ describe('ContactManager', function () {
|
||||||
'./mongodb': {
|
'./mongodb': {
|
||||||
db: (this.db = { contacts: {} }),
|
db: (this.db = { contacts: {} }),
|
||||||
ObjectId
|
ObjectId
|
||||||
},
|
}
|
||||||
'logger-sharelatex': { log: sinon.stub() },
|
|
||||||
'@overleaf/metrics': { timeAsyncMethod: sinon.stub() }
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.user_id = ObjectId().toString()
|
this.user_id = ObjectId().toString()
|
||||||
|
|
|
@ -21,8 +21,7 @@ describe('HttpController', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.HttpController = SandboxedModule.require(modulePath, {
|
this.HttpController = SandboxedModule.require(modulePath, {
|
||||||
requires: {
|
requires: {
|
||||||
'./ContactManager': (this.ContactManager = {}),
|
'./ContactManager': (this.ContactManager = {})
|
||||||
'logger-sharelatex': (this.logger = { log: sinon.stub() })
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.user_id = 'mock-user-id'
|
this.user_id = 'mock-user-id'
|
||||||
|
|
Loading…
Reference in a new issue