Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import { fixture, test } from 'testcafe' #1735

Closed
arty-name opened this issue Aug 28, 2017 · 5 comments · Fixed by #6338
Closed

import { fixture, test } from 'testcafe' #1735

arty-name opened this issue Aug 28, 2017 · 5 comments · Fixed by #6338
Assignees
Labels
FREQUENCY: level 2 TYPE: enhancement The accepted proposal for future implementation.

Comments

@arty-name
Copy link

Are you requesting a feature or reporting a bug?

I am requesting a feature

What is the current behavior?

feature and test are globals and have to be configured as such in ESLint

What is the expected behavior?

I would like to avoid globals in the same way as I do in mocha: by importing the necessary functions from testcafe:

import { fixture, test } from 'testcafe'

Specify your

  • operating system: Ubuntu
  • testcafe version: 0.17.1
  • node.js version: 8.4
@renanbastos93
Copy link

@AndreyBelym this issue https://github.com/DevExpress/testcafe/issues/3940

it was don't resolved, I tested your suggestion but don't a success.

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Sep 11, 2019
@Farfurix Farfurix self-assigned this Sep 12, 2019
@Farfurix
Copy link
Contributor

@renanbastos93

Hello,

I've prepared an example to import both fixture and test. In the following example, you need to specify your tests as either a set of files or a glob pattern.
testcafe-defs.js:

export const fixture = (...args) => global.fixture(...args);
export const test    = (...args) => global.test(...args);

test-1.js:

import { fixture, test } from './testcafe-defs';
import { Selector } from 'testcafe';

fixture `Fixture 1`
    .page `https://google.com`;

test('test 1', async t => {
    await t
        .typeText(Selector('#tsf > div:nth-child(2) > div.A8SBwf > div.RNNXgb > div > div.a4bIc > input'), 'TestCafe')
        .pressKey('enter');
});

test-2.js:

import { fixture, test } from './testcafe-defs';
import { Selector } from 'testcafe';

fixture `Fixture 2`
    .page `https://google.com`;

test('test 2', async t => {
    await t
        .typeText(Selector('#tsf > div:nth-child(2) > div.A8SBwf > div.RNNXgb > div > div.a4bIc > input'), 'TestCafe')
        .pressKey('enter');
});

TestCafe command:

testcafe chrome test-*.js

TestCafe runner:

const createTestCafe = require('testcafe');
let testcafe         = null;

createTestCafe('localhost', 1337, 1338)
    .then(tc => {
        testcafe     = tc;
        const runner = testcafe.createRunner();

        return runner
            .src(['tests/test-*.js'])
            .browsers(['chrome'])
            .run();
    })
    .then(failedCount => {
        console.log('Tests failed: ' + failedCount);
        testcafe.close();
    });

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Sep 12, 2019
@renanbastos93
Copy link

@Farfurix thanks a lot

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Sep 12, 2019
@Farfurix
Copy link
Contributor

@renanbastos93

You are welcome.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Sep 12, 2019
@renanbastos93
Copy link

To complement this information, we can take another approach:

Create file below:

.testcaferc.json

"src": ["./clear.js","./tests/**/main.js"]

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Sep 17, 2019
@Farfurix Farfurix removed their assignment Sep 17, 2019
@arubtsov arubtsov removed the STATE: Need response An issue that requires a response or attention from the team. label Sep 18, 2019
@AndreyBelym AndreyBelym added STATE: Stale An outdated issue that will be automatically closed by the Stale bot. FREQUENCY: level 2 and removed STATE: Stale An outdated issue that will be automatically closed by the Stale bot. labels Oct 19, 2020
@Aleksey28 Aleksey28 self-assigned this Jun 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FREQUENCY: level 2 TYPE: enhancement The accepted proposal for future implementation.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants