• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

realm / realm-js / 5541616547

13 Jul 2023 09:53AM UTC coverage: 85.292% (-0.6%) from 85.909%
5541616547

push

github

LJ
Test that property values are correctly updated.

881 of 1096 branches covered (80.38%)

Branch coverage included in aggregate %.

2291 of 2623 relevant lines covered (87.34%)

791.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/packages/realm/src/tests/utils.ts
1
////////////////////////////////////////////////////////////////////////////
2
//
3
// Copyright 2022 Realm Inc.
4
//
5
// Licensed under the Apache License, Version 2.0 (the "License");
6
// you may not use this file except in compliance with the License.
7
// You may obtain a copy of the License at
8
//
9
// http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing, software
12
// distributed under the License is distributed on an "AS IS" BASIS,
13
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
// See the License for the specific language governing permissions and
15
// limitations under the License.
16
//
17
////////////////////////////////////////////////////////////////////////////
18

19
import path from "node:path";
20
import fs from "node:fs";
21
import { fileURLToPath } from "node:url";
22

23
import type { Realm } from "../index";
24

25
export type RealmContext = Mocha.Context & { realm: Realm };
26

27
export function generateRandomInteger() {
28
  return Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
×
29
}
30

31
export const REALMS_DIR = fileURLToPath(new URL("realms", import.meta.url));
×
32
export const REALMS_TEMP_DIR = path.resolve(REALMS_DIR, "temp");
×
33
if (!fs.existsSync(REALMS_TEMP_DIR)) {
×
34
  fs.mkdirSync(REALMS_TEMP_DIR, { recursive: true });
×
35
}
36

37
export function generateTempRealmPath() {
38
  return path.resolve(REALMS_TEMP_DIR, "random-" + generateRandomInteger() + ".realm");
×
39
}
40

41
export function closeRealm(this: Mocha.Context & Partial<RealmContext>) {
42
  if (this.realm && !this.realm.isClosed) {
×
43
    this.realm.close();
×
44
    delete this.realm;
×
45
  }
46
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc