1

This is my first post on here (ever), so please bear with me if I don't supply all of the necessary information (I will always edit to add more information as required). I am new to QA, especially automation testing.

I have a Typescript (v4.9.5) project I am running on a node (v18.5.0) server where I am trying to run some automation tests using WebdriverIO (v^8.7.0) and Appium (v^1.22.3) (with Mocha v^10.2.0 for unit testing).

Here's my package.json file:

{
...
    "dependencies": {
        "@capacitor-community/bluetooth-le": "^2.1.0",
        "@capacitor/android": "4.6.3",
        "@capacitor/app": "4.1.1",
        "@capacitor/core": "4.6.3",
        "@capacitor/haptics": "4.1.0",
        "@capacitor/keyboard": "4.1.1",
        "@capacitor/status-bar": "4.1.1",
        "@ionic/react": "^6.0.0",
        "@ionic/react-router": "^6.0.0",
        "@testing-library/jest-dom": "^5.11.9",
        "@testing-library/react": "^13.3.0",
        "@testing-library/user-event": "^12.6.3",
        "@types/node": "^12.19.15",
        "@types/react": "^18.0.17",
        "@types/react-dom": "^18.0.6",
        "@types/react-router": "^5.1.11",
        "@types/react-router-dom": "^5.1.7",
        "ble-wrapper": "^1.0.7",
    ...
    },
...
    "eslintConfig": {
        "extends": [
            "react-app",
            "react-app/jest"
        ]
    },
    enter code here
        "development": [
            "last 1 chrome version",
            "last 1 firefox version",
            "last 1 safari version"
        ]
    },
    ...
    "devDependencies": {
        "@babel/cli": "^7.21.0",
        "@babel/core": "^7.21.4",
        "@babel/preset-env": "^7.21.4",
        "@babel/register": "^7.21.0",
        "@capacitor/cli": "^4.6.3",
        "@types/chai": "^4.3.4",
        "@types/jquery": "^3.5.16",
        "@types/mocha": "^10.0.1",
        "@types/web-bluetooth": "^0.0.16",
        "@types/webdriverio": "^5.0.0",
        "@wdio/allure-reporter": "^8.6.8",
        "@wdio/appium-service": "^8.7.0",
        "@wdio/cli": "^8.7.0",
        "@wdio/devtools-service": "^8.7.0",
        "@wdio/globals": "^8.6.9",
        "@wdio/local-runner": "^8.7.0",
        "@wdio/mocha-framework": "^8.7.0",
        "@wdio/spec-reporter": "^8.6.8",
        "@wdio/sync": "^7.27.0",
        "@wdio/types": "^8.6.8",
        "allure-commandline": "^2.21.0",
        "appium": "^1.22.3",
        "appium-uiautomator2-driver": "^2.14.0",
        "chai": "^4.3.7",
        "mocha": "^10.2.0",
        "ts-node": "^10.9.1",
        "typescript": "^4.9.5",
        "webdriverio": "^8.7.0"
    },
}

My tsconfig.json file:

{
  "compilerOptions": {
    "target": "es2022",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "commonjs",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx",
    "outDir": "./dist",
    "types": [
      "node",
      "mocha",
      "webdriverio/async",
      "@wdio/mocha-framework",
      "@wdio/globals/types",
      "@wdio/types"
    ]
  },
  "include": [
    "src"
  ],
  "exclude": [
    "node_modules"
  ]
}

The test I'm trying to run on my android device:

import { Browser } from 'webdriverio';

let device: Browser;

describe('Open and close drawer', async () => {
    it('Open drawer', async () => {
        await $('//*[@text="OPEN DRAWER"]').click();
        // await device.pause(3000);
        // const error = await $('//*[@resource-id="android:id/message"]')['error']
        if (await $('//*[@resource-id="android:id/message"]')) {
            await $('//*[@resource-id="android:id/button1"]').click()
        }
        expect($('alert-1-hdr')).toEqual("You've just clicked the Open Drawer button");
    });
});

And the results:

...
[9c000c72010648725d2 Android 11 #0-0] Unexpected return from a matcher function.
Matcher functions should return an object in the following format:
  {message?: string | function, pass: boolean}
'{"actual": {}, "expected": "You've just clicked the Open Drawer button", "message": [Function anonymous], "name": "toEqual", "pass": {}}' was returned
...

I'm running this on a Windows 10 Enterprise system using Powershell.

device is coming up as being unable to pause (or really do anything), and instead of using wdio for test files, it's using jQuery syntax. Does anyone know what I'm doing wrong here? I have followed every tutorial (including on wdio's website for Typescript) to fix this.

I am attempting to click a button on the main screen of the application using appium and webdriverio and verify that it was clicked (if there's a popup error, click the "OK" button).

Edit: I feel dumb, my tests were not in the src folder, so adding wdio.conf.ts and test directory to the "include" portion of tsconfig.json fixed this problem.

mdexter1
  • 11
  • 3

0 Answers0