最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

testing - GitHub tests take a long time - Stack Overflow

matteradmin6PV0评论

I have created the following /.github/workflows/testing.yml file:

name: Linting-And-Testing

on: [push, pull_request]

jobs:
  Linting-And-Testing:
    name: Linting-And-Testing
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install Dependencies
        run: npm install
      - name: Run linting
        run: npm run lint
      - name: Run tests
        run: npm test

The linting part of this file is correctly completed in seconds. However, the testing takes a long time.

When I manually run the tests for the same code on my computer, the tests finish running in seconds. However, on GitHub, they can take 6 hours to run.

The tests running are creating, reading, updating and deleting data from a Realm database.

An example of some of the tests:

describe("table", () => {
    let realm;

    beforeEach(() => {
        realm = new Realm({ "schema": [table] });
    });

    afterEach(async() => {
        realm.write(() => {
            realm.deleteAll(); // Clear all data in the database
        });
        await realm.close(); // Ensure Realm is closed after each test
    });
    
    test("Create table", () => {
        expect(realm.schema[0].name).toBe("Table");
    });

    test("Create record in table", () => {
        realm.write(() => {
            realm.create("Table", { "id": 1, "name": "Name", "notes": "Notes" });
        });
        const table = realm.objects("Table")[0];
        expect(table.id).toBe(1);
        expect(table.name).toBe("Name");
        expect(table.notes).toBe("Notes");
    });
});

I assume the reason is because the tests are running on Ubuntu instead of an Android or iOS device. If this is the reason, how would I be able to run the tests on an Android and iOS device.

Post a comment

comment list (0)

  1. No comments so far