Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
before(function() {
url = `${elasticsearchConnections.host}:${elasticsearchConnections.port}`;
// Enable nock if it has been disabled by other specs
if (!nock.isActive()) nock.activate();
// Uncomment to test dockerized server:
//
// elasticsearchConnections.host = 'http://localhost';
// elasticsearchConnections.port = '9200';
// nock.restore();
});
before(() => {
if (!nock.isActive()) {
nock.activate();
}
return server.start()
.then(() => {
// Do preparation requests to force siteInfo fetch so that we don't need to mock it
return P.join(
preq.get({uri: `${server.config.bucketURL()}/title/Main_Page`}),
preq.get({uri: `${server.config.bucketURL('ru.wikipedia.beta.wmflabs.org')}/title/${encodeURIComponent('Заглавная_страница')}`})
);
});
});
after(() => server.stop());
before(function() {
// Enable nock if it has been disabled by other specs
if (!nock.isActive()) nock.activate();
});
function beforeTest(cassettePath, options) {
nockReset();
// I feel like this could be written better. Some duplication here
if (options.mode === 'all') {
nockStartRecording();
} else if (fs.existsSync(cassettePath)) {
if (!nock.isActive()) {
nock.activate();
}
nock.load(cassettePath);
} else {
nockStartRecording();
}
}
activateMocking() {
if (!nock.isActive()) {
nock.activate();
}
}
export const balenaAPIMock = () => {
if (!nock.isActive()) {
nock.activate();
}
return nock(/./)
.get('/config/vars')
.reply(200, {
reservedNames: [],
reservedNamespaces: [],
invalidRegex: '/^d|W/',
whiteListedNames: [],
whiteListedNamespaces: [],
blackListedNames: [],
configVarSchema: [],
});
};
constructor() {
nock.cleanAll();
if (!nock.isActive()) {
nock.activate();
}
this.scope = nock(BalenaAPIMock.basePathPattern);
nock.emitter.on('no match', this.handleUnexpectedRequest);
}
beforeAll(() => {
Swagger.clearCache()
if (!nock.isActive()) {
nock.activate()
}
nock.cleanAll()
nock.disableNetConnect()
const nockScope = nock('http://mock.swagger.test')
if (currentCase.remoteDocuments) {
Object.keys(currentCase.remoteDocuments).forEach((key) => {
const docContent = currentCase.remoteDocuments[key]
nockScope
.get(`/${key}`)
.reply(200, docContent, {
'Content-Type': 'application/yaml'
})
beforeEach(() => {
if (!nock.isActive()) {
nock.activate();
}
});
beforeEach(() => {
if (!nock.isActive()) nock.activate();
nock.disableNetConnect();
});