React native test error - beforeAll is not defined

I am trying to run an appium test as described here, https://blog.logrocket.com/testing-your-react-native-app-with-appium/

I am trying to run a test to confirm two buttons exists on the page.

However, I get an error - how can I get my basic test to work?

    > [email protected] test /Users/user/apps/myracnative/appium
    > mocha test/basic
    
    
    ReferenceError: beforeAll is not defined
        at Object.<anonymous> (/Users/user/apps/myracnative/appium/test/basic/index.js:16:1)

index.js

const wd = require("wd");
const jasmine = require("jasmine");
jasmine.DEFAULT_TIMEOUT_INTERVAL = 600000;
const PORT = 4723;

const config = {
    platformName: "iOS",
    platformVersion: "14.4",
    deviceName: "iPhone 11",
    app: "../../../apps/myracnative.ipa",
    automationName: "XCUITest", // UiAutomator2, Espresso, or UiAutomator1 for Android
};

const driver = wd.promiseChainRemote("localhost", PORT);

beforeAll(async () => {
    await driver.init(config);
});

test("Test Accessibilty Id", async () => {
    expect(
        await driver.hasElementByAccessibilityId("Create account")
    ).toBe(true);
    expect(await driver.hasElementByAccessibilityId("Log in")).toBe(true);
});

First, I’d like to thank you for providing a link to the tutorial that you are following. Very few people do that on this board, and it really makes it easier to help if the tutorial is referenced.

I’m not a javascript expert, but it looks to me like this person is using Jasmine to get beforeAll methods. When I look at the examples on the Jasmine github page:

They are using them in this manner:

describe 'test description'
  beforeAll -> someBeforeAction
  
  context 'some context'

So I think you need to add an enclosing describe method to the tests.

More examples:

https://www.tabnine.com/code/javascript/functions/jasmine/beforeAll

And here is the full Jasmine documentation:

https://jasmine.github.io/