Xstate: Chalk dependency makes it impossible to execute tests inside a browser with @xstate/test

Created on 11 Oct 2019  路  1Comment  路  Source: davidkpiano/xstate

Thanks so much for xstate!

Description
I'm trying to implement model based tests with @xstate/test in an ember.js project and the hard dependency on chalk breaks the test-suite as ember tests are executed in a browser environment.
Thanks for xstate!

Expected Result

Being able to execute model-based tests independent of node or browser environment - colorful output is nice but will most likely also be handled by the used test-runner. It might also be possible to create some kind of data structure that describes the error and then use that data-structure later on to optionally color the output of the error message.

Actual Result
My test breaks with

ReferenceError: process is not defined

as chalk is not designed to work in a browser environment.

Reproduction
I did not add a reproduction as I don't have a sandbox available that runs ember + xstate. I'll add a screenshot for reference though.

xstate-test-error

You can ignore the ember-auto-import part - the error message just tells us that the code breaks when requiring chalk.

Additional context
Removing require('chalk') and calls to chalk from the compiled code for @xstate/test gets rid of the errors and I can execute my test-suite.

Notes
Happy to fix this if you tell me how you can imagine getting rid of chalk in browser runs.

bug

Most helpful comment

Gonna prepare package tweaks a little bit later today to enable running them in browsers.

>All comments

Gonna prepare package tweaks a little bit later today to enable running them in browsers.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

drmikecrowe picture drmikecrowe  路  3Comments

dakom picture dakom  路  3Comments

hnordt picture hnordt  路  3Comments

amelon picture amelon  路  3Comments

carloslfu picture carloslfu  路  3Comments