Having trouble getting Chutzpah to work with TypeScript references

I am currently working on a project where my project folder contains the following files:

  • chai.d.ts
  • chai.js
  • mocha.d.ts
  • mocha.js
  • appTest.ts
  • appTest.js
  • chutzpah.json

The chai and mocha files were acquired through bower and tsd.

Let's take a look at the content of the other files:

appTest.ts:

/// <chutzpah_reference path="mocha.js" />
/// <chutzpah_reference path="chai.js" />
/// <reference path="mocha.d.ts" />
/// <reference path="chai.d.ts" />
var assert = chai.assert;

test("test test", function () {
    assert.equal(1, 3, "One equals three");
});

appTest.js: (compiled by external process)

var assert = chai.assert;
test("test test", function () {
    assert.equal(1, 3, "One equals three");
});

chutzpah.json:

{
  "Compile": {
    "Mode": "External",
    "Extensions": [ ".ts" ],
    "ExtensionsWithNoOutput": [ ".d.ts" ]
  },
  "Tests": [
    {
      "Includes": [ "*Test.ts" ]
    }
  ]
}

After running the command below within the folder:

chutzpah.console appTest.ts

An error is encountered as shown:

Chutzpah console test runner  (64-bit .NET 4.0.30319.42000)
Version 4.1.0.0
Copyright (C) 2015 Matthew Manela (http://matthewmanela.com).


Error: ReferenceError: Can't find variable: chai
at global code in file:///C:/***/appTest.js (line 1)

While Running:C:\***\appTest.ts

File: C:\***\appTest.ts
     0 total, 0 failed, took 0.00 seconds

Tests complete: 0
=== 0 total, 0 failed, took 1.65 seconds ===

What could be the missing piece in this puzzle?

Answer №1

It appears that you may be encountering a situation resulting from a recent change in version 4.1 of Chutzpah where file references are now parsed differently when utilizing the Chutzpah.json file. To enhance performance, Chutzpah now allows scanning references within test files to be an optional feature and encourages explicitly listing them in the Chutzpah.json file.

For more detailed information, please visit this page.

In essence, you will need to either specify the necessary files in the chutzpah.json file:

 "References": [
    {
      "Path": "chai.js"
    }
  ]

or enable reference scanning in your test file by adding:

  "Tests": [
        { "Includes": [ "*Test.ts" ], "ExpandReferenceComments":  "true" }
    ]

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Can you explain the distinction between interfaces containing function properties written as "f()" and "f: () =>"?

Let's take a look at two interfaces, A and B: interface A {f(): number} interface B {f: () => number} I have experimented with the following: var a: A = {f: function() {return 1}} var a: A = {f: () => 1} var b: B = {f: function() {return 1}} ...

Dynamic addition of script to <head> element in Angular is a common task for many developers

I have explored some examples that illustrate how to dynamically add a script with a URL in Angular However, I am interested in adding this type of content to the <head> <script> !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(! ...

How to arrange data in angular/typescript in either ascending or descending order based on object key

Hey there! I'm fairly new to Angular and have been working on developing a COVID-19 app using Angular. This app consists of two main components - the State component and the District component. The State component displays a table listing all states, ...

Guidelines for returning an object upon finishing the .map function within a promise-based function in Node.js

While working on server-side code using nodejs, I have encountered an issue with the .map() method inside a Promise. The problem is that the method returns a value before the .map() function completes its execution successfully. Here's the snippet of ...

Starting up a pre-existing Angular project on your local machine

I am completely new to Angular and facing difficulties running an existing project on my machine. Despite conducting numerous tests and following various articles, I still cannot get the project to run. Here is the layout of my project files: I have succ ...

Creating intricate mazes using canvas drawing techniques

I recently developed a maze generator as a personal project utilizing a graph. While the generation logic works perfectly, I am facing challenges when it comes to rendering the maze. In my approach, each cell is represented by an array of 4 edges where the ...

Execute a function that handles errors

I have a specific element that I would like to display in the event of an error while executing a graphql query (using Apollo's onError): export const ErrorContainer: React.FunctionComponent = () => { console.log('running container') ...

Using the function goToPage() within the TabbedHeaderPager component

I am currently working on a project that involves using TabbedHeaderPager, and I need to change tabs programmatically. I have been attempting to use the function goToPage() but have run into difficulties accessing it. I have tried passing it as a prop an ...

Error: Invalid connection string for ELF Lambda detected

Having an issue with a lambda function that connects to a remote MongoDB on an EC2 instance using TypeScript. While I can connect to the database locally, there is an ELF error when running in lambda. It seems to be related to mismatched binaries of npm pa ...

Tips for resolving the setAttribute() function error message: "Argument of type 'boolean' is not assignable to parameter of type 'string'"

I am currently working on a function that dynamically updates the HTML aria-expanded attribute based on whether it is true or false. However, when I declare element as HTMLElement, I encounter an error stating Argument of type 'boolean' is not as ...

What is the best way to switch routes in redux saga upon successful login?

Greetings! I'm a newcomer to React and I've been using React hooks and redux-saga for my project. I have a requirement where I need the router to navigate to /home upon successful login. I attempted to achieve this using connected-react-router an ...

The error message "Redux createStore<StoreState> requires 4 type arguments, but only received 1" is showing up

Currently, I am following a TypeScript-React-Starter tutorial where I am in the process of creating a store located in src/index.tsx. According to the tutorial, const store = createStore<StoreState>(enthusiasm, { enthusiasmLevel: 1, languageName ...

Issue regarding retrieving the image using TypeScript from an external API

Hey developers! I'm facing an issue with importing images from an external API. I used the tag: <img src = {photos [0] .src} /> but it doesn't seem to recognize the .src property. Can anyone shed some light on how this is supposed to work? ...

Unsteady movement of Three JS OrbitControls during rotation

Currently, I am working on a scene with three.js and using orbit controls to rotate the camera around the scene. Occasionally, while rotating, the camera starts moving erratically before calming down and rotating smoothly again. I have read about orbit co ...

How can TypeScript be used to enable CSV or PDF export in a material-react-table?

Is it possible to incorporate the ability to export data to CSV or PDF in a material-react-table? While I am familiar with how to do this with a Material UI table, I have not been able to find the same functionality for the material-react-table. Thank you ...

Does TypeScript lack awareness of type checking within nested functions?

Currently, I am using TypeScript with React and encountering a particular issue. Below is a function I have created to ensure that the variable 'arr' is an Array and not empty. export const isNotEmptyArr = (arr?: unknown[]) => { return Arra ...

Express throwing module errors

I encountered an issue while attempting to expose a REST service in an electron app using expressJS. Following a tutorial, I added express and @types/express to the project. However, when trying to implement a "get" method and running the build with ng bui ...

Tips for preventing the occurrence of a final empty line in Deno's TextLineStream

I executed this snippet of code: import { TextLineStream } from "https://deno.land/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7201061632425c4341445c42">[email protected]</a>/streams/mod.ts"; const cm ...

Ways to avoid using a specific type in TypeScript

Imagine having a class that wraps around a value like this: class Data<T> { constructor(public val: T){} set(newVal: T) { this.val = newVal; } } const a = new Data('hello'); a.set('world'); // typeof a --> Primitiv ...

Is it possible to remove a complete row in Angular 2 using Material Design

JSON [ { position: 1, name: 'test', value: 1.0079, symbol: 'HHH' }, { position: 2, name: 'test2', value: 4.0026, symbol: 'BBB' }, { position: 3, name: 'test3', value: 6.941, symbol: 'BB' }, ...