scottdurow / dataverse-ify

Easily call the Dataverse WebApi from TypeScript using SDK style types, with a NodeJS implementation for integration testing.
MIT License
57 stars 14 forks source link

config.server not configured on integration test #19

Closed kayetter closed 2 years ago

kayetter commented 2 years ago

I can't seem to get my config.server configured. When I run "jest integration" in terminal I get the following error:

config.server not configured

  at Function.<anonymous> (node_modules/dataverse-ify/src/webapi/XrmStatic.ts:26:15)
  at node_modules/dataverse-ify/lib/webapi/XrmStatic.js:8:71
  at Object.<anonymous>.__awaiter (node_modules/dataverse-ify/lib/webapi/XrmStatic.js:4:12)
  at Function.createInstance (node_modules/dataverse-ify/lib/webapi/XrmStatic.js:17:16)
  at node_modules/dataverse-ify/src/webapi/SetupGlobalContext.ts:36:39
  at node_modules/dataverse-ify/lib/webapi/SetupGlobalContext.js:8:71

My configuration is as follows:

  1. test.yaml file is present in a config folder directly under the root directory. Am I missing a step to configure credentials?

  2. test.yaml contains the following configuration: nodewebapi: logging: verbose server: host: https://[my environment].dynamics.com version: 9.1 however in the dataverse-ify integration instructions it says to use this: nodecds: server: host: https://someorg.crm11.dynamics.com version: 9.1

  3. import { SetupGlobalContext } from "dataverse-ify/lib/webapi"; present in integration.AccountRibbon.test.ts

  4. serviceClient set to const serviceClient = new XrmContextCdsServiceClient(Xrm.WebApi);

  5. Ran npx node-cds-auth to get refreshToken

I tried updating the version in the test.yaml to 9.2. I also tried using a host = "https://[my environment].api.crm.dynamics.com"

Can you help me troubleshoot what I might be missing in my configuration?

scottdurow commented 2 years ago

Hi @kayetter - I think the issue here is that you are using node-cds-auth and the test.yaml for cdsify - but the integration test code for dataverse-ify.

I'd recommend using dataverse-ify rather that cdsify.

So you would ened to use the nodewebapi in your test.yaml, and use dataverse-auth

I've updated the docs which still had the old cdsify info which I suspect was the cause of confusion!

kayetter commented 2 years ago

Thank you so much for the response! I was confused with node-cds-auth so I tried again with the dataverse-auth. While I did get an error it is a different error : "No token found for environment". See the screen shot below of my terminal and the successful token. And then the error when trying to run the integration test. Obviously I am missing some other configuration?

image

scottdurow commented 2 years ago

Hi @kayetter you might have got round this by now - but it seems the issue could just be as simple as there being a trailing / in your test.yaml file.

Instead of:

nodewebapi:
 server:
  host: https://org.api.crm3.dynamics.com
  version: 9.1

Use:

nodewebapi:
 server:
  host: https://org.api.crm3.dynamics.com/
  version: 9.1

I'll add an issue to make dataverse-ify more forgiving of this!

scottdurow commented 2 years ago

Tracked in #21