Skip to content

Usage with @jest-runner/electron #38

Description

@dietergeerts

Hi, I'm trying to use this in electron, but the sass module can't be found. I get an "Illigal invocation" error, and I'm not proficient enough with electron to know what is going on, and how to update configuration to get this package working with the @jest-runner/electron one. I need an actual browser and rendering because I want to test the eventual colours of elements. So any help is very appreciated.

This is my config:

jest-config.js

  //...
  displayName: 'Real browser',
  runner: require.resolve('@jest-runner/electron'),
  testEnvironment: require.resolve('@jest-runner/electron/environment'),
  testMatch: ['**/*.spec.{???,??}'],
  transform: {
    '\\.(scss|css)$': require.resolve('jest-css-modules-transform'),
  },
  //...

jest-css-modules-transform-config.js

const sharedPostcssConfig = require('@company/tools-config-postcss');

module.exports = {
  injectIntoDOM: true,
  sassModuleName: require.resolve('sass'),
  postcssConfig: sharedPostcssConfig(null, { mode: 'none' }),
};

Activity

  1. dietergeerts commented on May 19, 2021

    @dietergeerts
    Author

    After looking deeper, and further, I couldn't figure out how to get it working, and I ended up using another similar package with this one, now my config is as follows, and is working as expected:

      //...
      displayName: 'Real browser',
      runner: require.resolve('jest-electron/runner'),
      testEnvironment: require.resolve('jest-electron/environment'),
      // runner: require.resolve('@jest-runner/electron'),
      // testEnvironment: require.resolve('@jest-runner/electron/environment'),
      testMatch: ['**/*.spec.{???,??}'],
      transform: {
        '\\.(scss|css)$': require.resolve('jest-css-modules-transform'),
      },
      //...

    So if others encounter this too, there is another package that works, though it seems that it's an abandoned one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions