Xform error when trying to run tests with cht-conf-test-harness

I get this error when I try to run my tests. This occurs when I try and fill a contact form using harness.fillContactCreateForm
Error: XForm not available at path:

It is possible to specify a different directory, but by default the harness assumes the directory the process is running in is the “base directory”. From this base directory, the harness will try to load the contact forms from ./forms/contact/{form_name}.xml. If you are not executing the tests from the root directory of your config folder, the harness might not be looking in the correct place for your form.

It would be helpful to know more about your particular setup. How are you executing your tests? What does the folder structure for your project look like? Can you post the exact code you are using for the fillContactCreateForm call?

Hi @jkuester
Thanks for the response. My setup is as follows:

CHT 4.1.0    
cht-conf: "^3.7.0",
cht-conf-test-harness: "^2.4.2",

Here is a sample snippet of code for testing:

const { expect } = require('chai');
const TestRunner = require('cht-conf-test-harness');
const { deathReportScenarios, facultyCreationScenarios } = require('../form-inputs');
const harnessDefaults = require('../../../harness.defaults.json');

const harness = new TestRunner();
const TODAY = '2023-03-15';

describe('Faculty create form', () => {
  before(() => harness.start());

  after(() => harness.stop());

    async() => {
      await harness.clear();
      await harness.setNow(new Date(TODAY));

  afterEach(() => expect(harness.consoleErrors).to.be.empty);

  it('saves data succesfully when faculty is created without faculty head', async() => {
    const result = await harness.fillContactCreateForm('faculty_create', ...facultyCreationScenarios.full);


In this snippet, I reference the faculty_create form which is located in ./forms/contact/faculty_create.xml
This is the errror I get: Error: XForm not available at path: /PATH_TO_PROJECT/forms/contact/faculty_create-create.xml Looks like it appends -create in the file name. Not sure why.

Ahhh, this is probably it! The naming structure for contact forms is specific. According to the docs, for contact forms:

The naming convention used should be <contact_type_id-{create|edit}>.xlsx.

So, it is expected that your contact form name will end with -create (and not _create).

Then, in the cht-conf-test-harness, the docs for the fillContactCreateForm method indicate that the first parameter is just the “Type of contact that should be created” and not the exact contact form name. The harness automatically fills in the -create part when it looks up the form.

So, can you try renaming your form to faculty-create and then use fillContactCreateForm('faculty'... to fill it?

Thanks @jkuester . This solves it!