Skip to content

Commit

Permalink
test: Turn off randomizer
Browse files Browse the repository at this point in the history
  • Loading branch information
dplewis committed Jul 7, 2024
1 parent 2ecc5a5 commit 544522c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
28 changes: 19 additions & 9 deletions spec/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ const defaultConfiguration = {
directAccess: true,
silent,
logLevel,
liveQuery: {
classNames: ['TestObject'],
},
startLiveQueryServer: true,
fileUpload: {
enableForPublic: true,
enableForAnonymousUser: true,
Expand Down Expand Up @@ -162,15 +166,16 @@ const destroyAliveConnections = function () {
}
};
// Set up a default API server for testing with default configuration.
let server;

let parseServer;
let didChangeConfiguration = false;

// Allows testing specific configurations of Parse Server
const reconfigureServer = async (changedConfiguration = {}) => {
if (server) {
await new Promise(resolve => server.close(resolve));
server = undefined;
if (parseServer) {
destroyAliveConnections();
await parseServer.handleShutdown();
await new Promise(resolve => parseServer.server.close(resolve));
parseServer = undefined;
return reconfigureServer(changedConfiguration);
}
didChangeConfiguration = Object.keys(changedConfiguration).length !== 0;
Expand All @@ -179,14 +184,20 @@ const reconfigureServer = async (changedConfiguration = {}) => {
port,
});
cache.clear();
const parseServer = await ParseServer.startApp(newConfiguration);
server = parseServer.server;
parseServer = await ParseServer.startApp(newConfiguration);
Parse.CoreManager.setRESTController(RESTController);
parseServer.expressApp.use('/1', err => {
console.error(err);
fail('should not call next');
});
server.on('connection', connection => {
parseServer.liveQueryServer?.server?.on('connection', connection => {
const key = `${connection.remoteAddress}:${connection.remotePort}`;
openConnections[key] = connection;
connection.on('close', () => {
delete openConnections[key];
});
});
parseServer.server.on('connection', connection => {
const key = `${connection.remoteAddress}:${connection.remotePort}`;
openConnections[key] = connection;
connection.on('close', () => {
Expand Down Expand Up @@ -223,7 +234,6 @@ afterEach(function (done) {
if (Object.keys(openConnections).length > 0) {
console.warn('There were open connections to the server left after the test finished');
}
destroyAliveConnections();
await TestUtils.destroyAllDataPermanently(true);
SchemaCache.clear();
if (didChangeConfiguration) {
Expand Down
2 changes: 1 addition & 1 deletion spec/support/jasmine.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"spec_dir": "spec",
"spec_files": ["*spec.js"],
"helpers": ["helper.js"],
"random": true
"random": false
}

0 comments on commit 544522c

Please sign in to comment.