Skip to content

[web-test-runner-plugin] How to set up global assertions #3208

Answered by IanVS
IanVS asked this question in Q&A
Discussion options

You must be logged in to vote

I think I've figured this out, actually. I've added a file called src/test-setup/expect.ts. It has to be in one of the mounted directories, that tripped me up a bit at first. Then, I can use testRunnerHtml and point to /dist/test-setup/expect.js, which is the name of the file after snowpack transforms it. So, I end up with something like:

/* src/test-setup/expect.ts */

import 'buffer';
import expect from 'expect';

window.expect = expect;

and

/* web-test-runner.config.cjs */
module.exports = {
  files: ['src/**/*.test.{ts,tsx}'],
  plugins: [require('@snowpack/web-test-runner-plugin')()],
  testRunnerHtml: (testFramework) => `<html>
    <body>
      <script type="module" src="/dist/test…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by IanVS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant