testcafe icon indicating copy to clipboard operation
testcafe copied to clipboard

External API broken when called with TestCafe

Open ohlsen3000 opened this issue 4 years ago • 2 comments

What is your Scenario?

  1. Load API for HERE Maps
<script type="text/javascript" src="https://js.api.here.com/v3/3.1/mapsjs-core.js"></script>
<script type="text/javascript" src="https://js.api.here.com/v3/3.1/mapsjs-service.js"></script>
<script type="text/javascript" src="https://js.api.here.com/v3/3.1/mapsjs-ui.js"></script>
<script type="text/javascript" src="https://js.api.here.com/v3/3.1/mapsjs-mapevents.js"></script>
  1. Use HERE Map as React-Component:
const H = window.H;
const platform = new H.service.Platform({
         apikey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
});
const defaultLayers = platform.createDefaultLayers({ lg: mapConfig.lang });

const hMap = new H.Map(mapRef.current, defaultLayers.vector.normal.map, {
         bounds: buildViewport(H, mapConfig),
         pixelRatio: window.devicePixelRatio || 1,
});

What is the Current behavior?

Map Shows without any Problem when running in normal mode. When run with TestCafe an error occurrs:

JavaScript error details: TypeError: Cannot read properties of undefined (reading 'withCredentials')

What is the Expected behavior?

API works the same under 'normal' circumstances and in TestCafe

What is your public website URL? (or attach your complete example)

https://developer.here.com/tutorials/react/#code-examples

What is your TestCafe test code?

fixture`ExecutionSteps`.beforeEach(goToShipment);

test.only('click first step', async (t) => {
   await t
      .expect(jumboCheckBox1.exists)
      .ok()
      .expect(getClass(jumboCheckBox1))
      .notContains('checked')
      .click(jumboCheckBox1)
      .expect(getClass(jumboCheckBox1))
      .contains('checked');
});

Your complete configuration file

No response

Your complete test report

No response

Screenshots

No response

Steps to Reproduce

  1. Open HERE Map in Browser -> works
  2. Run TestCafe Test containing that same page
  3. JS-Error occurrs

TestCafe version

1.18.0

Node.js version

v14.17.6

Command-line arguments

testcafe chrome ./e2e/tests/MyTest.test.ts

Browser name(s) and version(s)

Chrome 97.0.4692.71

Platform(s) and version(s)

Windows 10

Other

No response

ohlsen3000 avatar Jan 11 '22 12:01 ohlsen3000

Hello,

I reproduced the problem on my side using the component from the link you shared: https://developer.here.com/tutorials/react/#code-examples. Please refer to this screencast: https://www.screencast.com/t/cpCr3KgNbp. I also attached the archive with the test project and test.js file. 6813.zip

dositec avatar Jan 12 '22 13:01 dositec

Hi @ohlsen3000,

This issue was fixed in Testcafe v1.18.5. Please update Testcafe to the latest v1.19.0. Feel free to contact us if you face any issues.

Aleksey28 avatar Jul 13 '22 09:07 Aleksey28