Skip to content

[🐛 Bug]: ui: tdd doesn't seem to have any effect #10175

@bhootd

Description

@bhootd

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

latest

Node.js Version

16.18.1

Mode

WDIO Testrunner

Which capabilities are you using?

{
        maxInstances: 5,
        browserName: 'chrome',
        acceptInsecureCerts: true,
        'goog:chromeOptions': {
            args: ['disable-web-security'],
        },
}

What happened?

  1. Configure mocha to use tdd in wdio.conf.js

  2. Use tdd functions in a component test (i.e., using browser runner).

  3. Test fails (see log below) trying to look for before.

What is your expected behavior?

wdio/mocha shouldn't be looking for before at all, because mocha is configured to use tdd.

How to reproduce the bug.

Use the following wdio.conf.js

export const config = {
    runner: ['browser', {
        preset: 'react',
        headless: !Boolean(process.env.DEBUG),
        viteConfig: (env) => {
            return {
                define: {
                    'process.env.NODE_ENV': JSON.stringify('test'),
                },
            };
        },
    }],

    specs: [
        // './tests-wdio/**/*.test.js',
        './tests-wdio/**/*.test.jsx',
    ],
    exclude: [
        // 'path/to/excluded/files'
    ],
    maxInstances: 10,
    capabilities: [{
        maxInstances: 5,
        browserName: 'chrome',
        acceptInsecureCerts: true,
        'goog:chromeOptions': {
            args: ['disable-web-security'],
        },
    }],
    logLevel: 'warn',
    bail: 0,
    baseUrl: '',
    waitforTimeout: 10000,
    connectionRetryTimeout: 120000,
    connectionRetryCount: 3,
    services: [
        'chromedriver',
        'geckodriver',
    ],
    framework: 'mocha',
    reporters: ['spec'],
    mochaOpts: {
        ui: 'tdd',
        // timeout: 60000,
    },
};

Use tdd functions in a component test (i.e., using browser runner).

suite('Test suite', function() {
    suiteSetup(async function() {
       // set up
    });

    test('run this test', async function() {
      // test code
    });
});

Run the test.

$ DEBUG=true npx wdio run ./wdio.conf.js

Relevant log output

Running this test ends with the following error in the browser console:

mocha.js?v=b32bc9c5:84 Uncaught (in promise) ReferenceError: before is not defined
    at MochaFramework.run (mocha.js?v=b32bc9c5:84:9)
run @ mocha.js?v=b32bc9c5:84

And the following error in the terminal console:

$ DEBUG=true npx wdio run ./wdio.conf.js

Execution of 1 workers started at 2023-04-12T09:35:10.772Z

[0-0] RUNNING in chrome - file:///tests-wdio/L2/login.test.jsx
[0-0] %cDownload the React DevTools for a better development experience: https://reactjs.org/link/react-devtools font-weight:bold
[0-0] 2023-04-12T09:35:23.796Z ERROR @wdio/runner: Failed to run browser tests with cid 0-0: Error: browser test timed out
[0-0]     at file:///Users/jayesh/project/node_modules/webdriverio/build/commands/browser/waitUntil.js:39:23
[0-0]     at processTicksAndRejections (node:internal/process/task_queues:96:5)
[0-0]     at async Proxy.wrapCommandFn (file:///Users/jayesh/project/node_modules/@wdio/utils/build/shim.js:72:29)
[0-0]     at async BrowserFramework.#loop (file:///Users/jayesh/project/node_modules/@wdio/runner/build/browser.js:86:13)
[0-0]     at async BrowserFramework.run (file:///Users/jayesh/project/node_modules/@wdio/runner/build/browser.js:39:30)
[0-0]     at async Runner.run (file:///Users/jayesh/project/node_modules/@wdio/runner/build/index.js:145:24)
[0-0]  Error:  browser test timed out
[0-0] FAILED in chrome - file:///tests-wdio/L2/login.test.jsx

Spec Files:	 0 passed, 1 failed, 1 total (100% completed) in 00:00:13

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions