Giter Club home page Giter Club logo

testcafe-cucumber's People

Contributors

azzra avatar benkirby-ten10 avatar cmasekar avatar rquellh avatar vvedachalam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

testcafe-cucumber's Issues

Support for Allure-JS

Hi,
First of all, thanks for creating this project which is helping me to integrate cucumber.

I would really appreciate if we can integrate the allure-js framework for reporting as well as we can use that for historical records.

Thanks,
Ash

Mocking HTTP Requests

Hello,
Can you give an example, how to implement the mocking feature to your tests?
According to testCafe, for mock response from server we need to write:

import { RequestLogger, RequestMock } from 'testcafe';

const logger = RequestLogger('http://example.com');
const mock = RequestMock()
.onRequestTo('http://external-service.com/api/')
.respond({ data: 'value' });

fixture My fixture
.page('http://example.com')
.requestHooks(logger);

test
.requestHooks(mock)
('My test', async t => {
await t
.click('#send-logged-request')
.expect(logger.count(() => true)).eql(1)
.removeRequestHooks(logger)
.click('#send-unlogged-request')
.expect(logger.count(() => true)).eql(1)
.addRequestHooks(logger)
.click('#send-logged-request')
.expect(logger.count(() => true)).eql(2);
})

But I can not find fixtures and tests in your steps.

setLocalStorageItem(key, value) Example

Hello, can you please provide an example of how and where to set setLocalStorageItem(key, value) within the code? I am unable to setLocalStorage with my token and have tried many different ways to no avail. Your response is very much appreciated. Thanks!

testcafe-cucumber integration with Docker, Browserstack or SauceLabs

Hi @rquellh,

I came across your code repository. It looks fantastic ๐Ÿ‘ .

I was able to run tests on my development machine straight forward enough.

I notice Testcafe supports testing with docker, saucelabs & browserstack. I'm new enough to Testcafe so I have only seen samples whereby integration with these providers have been through Testcafe command line. So my question would be, is their a way to run the tests against any of those providers given the way the tests are initiated in this project (via cucumberjs runner).

If their was a sample that would be very useful, because essentially I would think the project offering would be on par (if not better) with other alternatives (for example cucumberjs & protractor or cucumberjvm & selenium) which support that out of the box already.

Thoughts?

test to capture testCafeController fails if file already exists.

function createTestFile() {
fs.writeFileSync('test.js',
'import errorHandling from "./features/support/errorHandling.js";\n' +
'import testControllerHolder from "./features/support/testControllerHolder.js";\n\n' +
'fixture("fixture")\n' +
'test\n' +
'("test", testControllerHolder.capture)')
}

When i create this file manually and try to run, it fails and talks about not being able to find fixture. Even if I import it above alongside test like const { fixture, test} = require("testcafe");

But when it's generated during runtime, it works without any problem. Any reason to explain this? Thanks.

How to report function timeout more usefully?

Hi @rquellh ,

Thank you so much for this, I really like it! I took a lot of inspiration from you and also started doing my own cucumber-testcafe suite.

I have one question though: do you know how I report function timeouts properly? Let's say I have an element on a page (Selector) and testcafe waits for it 20 seconds but doesn't find it - Cucumber then in that case will just report "a function timed out", wheras testcafe would have said on which line it stopped. Is it somehow possible to access the testcafe report as well as the cucumber reporting?

I already tried it with the reporters specified by testcafe in the runner API, but they all don't log anything - only the list reporter prints out anything at all something, but this is only restricted to "Running tests on Chrome / Windows 10" and "Ran 1 test successfully" in the end.

const stream = fs.createWriteStream('report.json');

runner
    .src('tests/sample-fixture.js')
    .browsers('chrome')
    .reporter('json', stream)
    .reporter('list')
    .run()
    .then(failedCount => {
        stream.end();
    });

running test cases behind a proxy

I cloned this repo and did the following steps

  • npm install
  • npm test (to run the test cases)
    all test cases launch a blank browser and then timed out. I am guessing this is because I am behind a proxy.
    I see the following error in all tests
   ร— Before # features\support\hooks.js:46
       Error: function timed out, ensure the promise resolves within 20000 milliseconds
           at Timeout._onTimeout (C:\Users\A418097\Desktop\TestCafe\github\testCafeBDD\testcafe-cucumber\node_modules\cucumber\src\user_code_runner.js:61:18)
           at ontimeout (timers.js:482:11)
           at tryOnTimeout (timers.js:317:5)
           at Timer.listOnTimeout (timers.js:277:5)

and then this error as well

 ร— After # features\support\hooks.js:60
       ReferenceError: testController is not defined
           at Object.exports.addErrorToController (C:\Users\A418097\Desktop\TestCafe\github\testCafeBDD\testcafe-cucumber\features\support\errorHandling.js:5:5)
           at CustomWorld.<anonymous> (C:\Users\A418097\Desktop\TestCafe\github\testCafeBDD\testcafe-cucumber\features\support\hooks.js:65:23)

I am able to run testCafe cases without cucumber and I do that by adding this line to my package.json

 "scripts": {
    "test": "testcafe chrome Tests/ -e --proxy https.proxy.domain.com:8000"
  },

I am guessing this is the problem why the tests timeout. Could someone point me in the right direction.

Changing port

This may be a feature request; i'm not sure.

We're using remote browsers for browser-compatibility tests -- and iOS and OSX browsers do not like the standard 1338 port. With testcafe, I can set the port on which to connect to the browsers via the ports parameter, like this:

testcafe 'browserstack:iPad [email protected]' --ports 9000,9100 <tests>

However, we're not sure how to set that with testcafe-cucumber. Could someone give us some pointers on how to go about this? Thanks in advance!

Adding TestCafe Command Line Interface when running my OSX tests throw error: unknown option

Hello, hope somebody can help.
I have successfully been running all my TestCafe Cucumber tests on OSX with: ./node_modules/.bin/cucumber-js

I have also been able to run: $ ./node_modules/.bin/cucumber-js --world-parameters '{"browser": "firefox"}'

But I cannot add other TestCafe Command Line Interface when running my tests, as they are not recognised.
Example:
$ ./node_modules/.bin/cucumber-js --skip-js-errors
error: unknown option `--skip-js-errors'

In fact it seems I can only use commands from these docs: https://github.com/rquellh/testcafe-cucumber/wiki/Running-Tests

Is there a restriction here I am not aware of?

Parallel Run is not working

Hi,

I have tried running using the param '--parallel' and enabling concurrency in TestCafe but I'm getting an error saying:

Error: listen EADDRINUSE: address already in use :::1338

Is this an issue with TestCafe/CucumberJS?

Cheers
S

Overriding step definitions

I am trying to implement an inheritance/override model where I want to have a 'generic' step definition which will be imported in and specific steps overridden as necessary.

I was able to import the step definitions from my generic file, but the override (I used the same step definition name) seems to not be overriding the step definitions.
ex:
Generic file

Given('User navigates to x page', async () => {
  await pAPage.navigateTo('x')
});

Specific/inherited file

Given('User navigates to x page', async () => {
  await pAPage.navigateTo('y')
});

PS: Our software has a number of applications that are all similar but vary (differently) a bit from the base configuration based on the client. Having to define the common steps multiple times will create a maintenance nightmare. Hence we want to group the common step definitions in the generic file and import/override by client as needed.

Appreciate all the help in advance.

Using JQuery functions

import { ClientFunction } from 'testcafe'; or const {ClientFunction} = require('testcafe');

When I try to use ClientFunction for JQuery in Cucumber-Testcafe frame-work, I get below error.

"ClientFunction cannot implicitly resolve the test run in context of which it should be executed. If you need to call ClientFunction from the Node.js API callback,
pass the test controller manually via ClientFunction's .with({ boundTestRun: t }) method first. Note that you cannot execute ClientFunction outside the test code."

I'm trying to call below JQuery, can you help me how to call it '.with({ boundTestRun: t })'

returnDefValue: ClientFunction(function (pageElem) {
    return document.querySelectorAll(pageElem)[0].value;
}),

After few more tries, I wrapped JQuery in Client function like this :

returnDefValue: function (pageElem, t) {
return ClientFunction(document.querySelectorAll("select[name='dropdown-emailGroupBy']")[0].value).with({ boundTestRun: t });
},

it gives me the response , "ReferenceError: document is not defined"

===

So I'm not able to use the JQuery function with Cucumber, that is usually supported by a Client Function wrapper in testcafe ..

e.g export const returnDefValue = ClientFunction(function (pageElem) {
// window.scrollBy(0, 1000);
return document.querySelectorAll(pageElem)[0].value
});

Skip Features and Scenarios

Hi I tired using @tags on cli to skip features and scenarios and it didn't work. I am new to this so please provide an example on how to skip the Features and Scenarios when running tests.

Help with verifying the list row values

I am using the testcafe with cucumber. I have the following list row values as shown in the image and I need to verify the values shown in the list as per the expected text.
Screen Shot 2019-11-04 at 10 52 20 am

I am trying with below code where data is passed from the feature file,

for(let i = 0 ; i < 3 ; i++){         
        const fieldName = Selector("div.nba-meta-action>div.nba-row>div.nba-row-left").with({ boundTestRun: testController }).withText(data[i].field);
        testController.expect(fieldName.exists).ok();
        const fieldValue = Selector("div.nba-meta-action>div.nba-row>div.nba-row-right").with({ boundTestRun: testController }).withText(data[i].value);
        testController.expect(fieldValue.exists).ok();
    }

I get error as "errMsg: 'AssertionError: expected false to be truthy'".

Can someone please help here.

Thanks

Failure screenshot not added to report

Are you requesting a feature or reporting a bug?

Bug

What is the current behavior?

When you running a cucumber report the screenshot is not attached to the report on failure.

What is the expected behavior?

The screenshot should be attached to the report on failure.

How would you reproduce the current behavior (if this is a bug)?

Run a cucumber report with a failure and inspect the report.

Specify your:

operating system: Windows 10.0.0
nodejs version: 8.9.3

test cafe port already in use

Currently I'm running parallel executions but the issue is test cafe starts on 1338 and its not allowing to run the second script simultaneously as fetches the below error. Do we have any option where we can mention it as random so that another test cafe execution picks different port?

Any help is much appreciated. Thank you

Port already in use

setLocalStorageItem(key, value) Example

Hello, can you please provide an example of how and where to setLocalStorageItem(key, value) within the code? I am unable to setLocalStorage with my token and have tried many different ways to no avail. Your response is very much appreciated. Thanks!

Features folder restructuring - Bring pages, step_def and features file under e2e_tests

Hi
I renamed the features folder to e2e_tests, created features folder under e2e_tests and moved all the features file under features folder I change the path name for TestController and errorHandling as below
fs.writeFileSync('test.js',
'import errorHandling from "./e2e_tests/support/errorHandling.js";\n' +
'import testControllerHolder from "./e2e_tests/support/testControllerHolder.js";\n\n' +

If I run the a scenario or feature, it I am not getting error but none of the steps are executed
$ node ./node_modules/.bin/cucumber-js
(node:1491) ExperimentalWarning: The fs.promises API is experimental

0 scenarios
0 steps
0m00.000s
Done in 0.32s.

Any idea?
Thanks

Passing parameters

Hi there,
I'm wondering is there a way to make parametrization of step?
What I mean is to pass an array to the scenario or step and run the scenario several times with every element from array?

Thanks

Thank you

You are a good man!

Thanks for this awesome repository!!!!!

Sample Tests Consistently Fails On Before Hook With Chrome (Mac) & Edge (Win) Browsers

Hi there,

I ran the sample tests on a few browser configurations. I notice though the tests fail at the Before hook stage on some configuration types (chrome Mac) & (edge win). I think it fails at the 'waitForTestController' API call. It seems to fail on the second test for each feature file.

โœ– Before # features/support/hooks.js:46
Error: function timed out, ensure the promise resolves within 20000 milliseconds
at Timeout._onTimeout (/Users/bhrein.brannick/Documents/src/testcafe-cucumber/node_modules/cucumber/src/user_code_runner.js:61:18)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)

I guess this is a different type of failures as sample test scenario number 4 fails as expected due to a test assertion error, however what I describe above is due to setup failures. Incidentally the sample tests run ok (chrome win), (ie win) & (firefox Mac & Win). Let me know if you need any more info.

testControllerHolder.free() taking a bit longer

Hi!

Firstly, thank you for this awesome integration!

I'm using this on a poc to migrate my tests suite to testcafe. However, i've been facing a small issue:

It seems testControllerHolder.free(); is taking a little bit longer when the application which i'm working on to complete.

When this happens, the second test of my feature is not "allowed" to start and the browser "breaks".

Also, this only happens in chrome, everything else looks fine.

Currently i'm a little bit out of time to work on this, so i wrote a paliative:

//TODO: Forgive me oh god please
function waitFor () {
    return new Promise( (resolve) => {
        setTimeout( () => {
            resolve()
        }, 1000)
    })
}


After(async function () {
    fs.unlinkSync('test.js');    
    testControllerHolder.free();
    await waitFor()
});

But it would be interesting if we could handle this in a better way.

testController as boundTestRun not working when importing into another project.

I've used this as a baseline for creating a generic Cucumber/Testcafe Library of step definitions, and importing the support files and step definitions works fine so the 2nd project only container the .feature / BDD side of things.

However, when I then add a test/dummy example step definition in the 2nd project I get this error.

The "boundTestRun" option value is expected to be a test controller.

I've debugged and logged and everything seems to be as expected, so wondering is I'm missing something about how cucmberJS sets up the environment??

logging testController I have it as expected -

TestController {
  testRun: 
   TestRun {
     domain: null,
     _events: { done: [Function] },
     _eventsCount: 1,
     _maxListeners: undefined,
     uploadStorage: UploadStorage { uploadsRoot: '/Users/..../...-bdd' },
     id: 'RmElLchgu',
     cookies: Cookies { cookieJar: [CookieJar] },
....

Would like to use this approach so any help is appreciated and happy to provide more example or info if required.

thanks for the repo.

[Testcafe-cucumber] steps with multiple examples runs only once

"dependencies": {
"base64-img": "^1.0.4",
"cucumber": "^4.2.1",
"eslint": "^4.19.1",
"npm": "^6.0.0",
"testcafe": "^0.23.2"
},
I have been trying to run a scenario which looks something like this
@gpnotification
Feature: As a patient, I want to select my preferred GP Surgery
so that I can keep my GP informed of LOD online consultation

Background: A patient already added a product to basket and is on delivery page
    Given I am on delivery page on desktop

@verifyGPNotification
Scenario Outline: Verify that a patient can see GP notification on delivery page when Feature flag is ON
    And I choose my "<deliveryoptions>"
    When I access the page with feature flag ON
    Then I verify that I can see GP notification

    Examples:
        | deliveryoptions  |
        | nextdaydelivery  |
        | clickncollect    |
        | standarddelivery |

When I run - npm test - testcafe runs only for the first row in the example table. It doesnt iterate. I get the following output in console but there is nothing more to debug

[email protected] test C:\Users\krish.murthy\intellijworkspace\archive\testcafe-cucumber
cucumber-js.cmd

Running tests in:

  • Chrome 69.0.3497 / Windows 10.0.0

fixture
....... โˆš test

1 passed (40s)
npm ERR! Test failed. See above for more details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.