Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for clean exit from node #4556

Merged
merged 3 commits into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ x.x.x Release notes (yyyy-MM-dd)
### Internal
* Update token in integration test.
* Upgraded Realm Core from v11.12.0 to v11.13.0.
* Added a failing test case for Node.js scripts failing to exit cleanly ([#4556](https://github.com/realm/realm-js/pull/4556))

10.14.0 Release notes (2022-3-24)
=============================================================
Expand Down
31 changes: 31 additions & 0 deletions integration-tests/tests/src/node/clean-exit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
////////////////////////////////////////////////////////////////////////////
//
// Copyright 2022 Realm Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////

import { execSync } from "child_process";

describe("Clean exit for Node.js scripts", () => {
// Repro for https://github.com/realm/realm-js/issues/4535 - currently still failing
it.skip("exits cleanly when creating a new Realm.App", () => {
execSync(
`node -e 'const Realm = require("realm"); const app = new Realm.App({ id: "myapp-abcde" }); Realm.clearTestState();'`,
{
timeout: 5000,
Copy link
Member

@kraenhansen kraenhansen May 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this extends the timeout of the test? I.e. if it takes 3 seconds for the process to exit, it will fail although it didn't timeout. Could we read this timeout from the test's context instead?

Suggested change
timeout: 5000,
timeout: this.timeout - 100,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah, good spot. How about this change: 924c7db so that it never exceeds either the test timeout or 5000ms?

I think 5000ms should always be enough for this test in any case, if you were running the suite with say 60 second timeout for some reason, there's no point in this one waiting for 60 seconds also.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea 👍 Looks great.

},
);
});
});
1 change: 1 addition & 0 deletions integration-tests/tests/src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@
// NOTE: This file is only supposed to be imported from a Node.js environment

import "./analytics";
import "./clean-exit";