Testcafe: Global Start URL Option

Created on 8 Nov 2017  路  14Comments  路  Source: DevExpress/testcafe

Are you requesting a feature or reporting a bug?

Request a feature

What is the current behavior?

Start Urls must be specified on fixtures or tests

What is the requested behavior?

It would be nice if I could set a global start url, instead of doing it for every fixture.

My app is a single page app, so for all tests, my start url is just localhost:PORT, and then I just navigate to the page I am testing with my app. It would be nice to only specify the start url in one spot on either the cmd line or the test runner (if using the node api).

I think it could be the lowest priority, so it would be overridden by a fixture.page call, which would then be overridden by test.page

level 2 enhancement

Most helpful comment

It's interesting how such a base feature is not being considered important.

All 14 comments

Hi @bdwain,

I feel it rather relates to test settings than to test run settings. I suppose it's a nice way to use a config file with baseUrl in this case as proposed in the forum discussion.

Yea i was doing something similar

import {getUrl} from './helpers';
fixture `Getting Started`
    .page(getUrl());

It just seemed like a global option would reduce the repetition since I have to say .page(getUrl()) in every file.

any chance this will be considered? I really think it will reduce repetition for tests of single page apps. E2E's will typically always just point to the root location (e.g. localhost:4567) and navigate from there using the app itself. It seems like a waste to have to specify it every time.

I would even argue that the location of the app itself is a test-run setting, since you might say run it locally (localhost:1234), or hit my preprod environment (preprod.foo.com), or my prod environment (prod.foo.com). Either way that is almost always global for the test run, and not differing by fixture or file.

I could make a PR to do it if it would be considered.

Hi @bdwain, thanks for your offer to help. I think we'll discuss in a near future changes in a way how you can setup settings for the whole test run, and we'll consider the url options too. We'll notify you once we have any news

sounds good!

any news?

Hi @stalniy, there is no such option yet, but you can use this approach.

Sorry to revive an old issue, but to elaborate on this a bit, this was my solution:

// ./testcafe.conf.ts|js
const config = {
  // Replace localhost:4200 with your baseUrl
  baseUrl: 'localhost:4200'
};

export { config };
// ./helpers/url.helper.ts|js
import { config } from '../testcafe.conf';

function urlFor(route) {
  return `${config.baseUrl}/${route}`;
}

export { urlFor };

```typescript
// ./src/dashboard.e2e-spec.ts|js
import { urlFor } from '../helpers/url.helper';

fixture('dashboard').page(urlFor('dashboard'));

// ...
````

I'm running my tests in an Angular environment, so please adjust accordingly.

Thank you for sharing your solution with us. We will take it into account when implementing this option.

One more request from https://isc.devexpress.com/Thread/WorkplaceDetails/T746291

My application has multiple environments/deployments with different URLs: development, staging, production.
Is there a way I can automatically run tests against multiple environments?

It's interesting how such a base feature is not being considered important.

Another request from the Support Center: Possibility to feed the URL of the page under test from the console

Is it possible to pass the test env in the console when running the test command and not from the file?

Example:
testcafe chrome ./ URL: "https://ourpageundertest.com/"

One more request from https://supportcenter.devexpress.com/internal/ticket/details/T947417

Changing the url of all fixtures at directory level before running a test

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hinok picture hinok  路  3Comments

Lukas-Kullmann picture Lukas-Kullmann  路  3Comments

ParachuteCat picture ParachuteCat  路  3Comments

madroneropaulo picture madroneropaulo  路  3Comments

multivoltage picture multivoltage  路  3Comments