selenium-ide: Unable to run test for packages

💬 Questions and Help

Hello, I’m building a new exporter and I’m trying to follow those instructions - I know they are quite dated.

I copied an existing exporter and I’m trying to run test.

I’ve installed all dependencies via pnpm and I’m running the test like so (from the rood dir)

pnpm run test --testMatch "**/packages/code-export-javascript-mocha/**/*.js"

It seems the jest/typescript setup is unable to cope with exporters tests, I’m getting the following error(s)

 FAIL  packages/code-export-javascript-mocha/__test__/src/selection.spec.js
  ● Test suite failed to run

    packages/code-export-javascript-mocha/src/selection.ts:18:40 - error TS2307: Cannot find module '@seleniumhq/side-code-export' or its corresponding type declarations.

    18 import { codeExport as exporter } from '@seleniumhq/side-code-export'
                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

There are multiple errors of the same nature, in relation to side-code-export and side-model

I tried modifying jest and typescript config as follows:

jest by adding entries to moduleNameMapper

// jest.config.js
module.exports = {
  testURL: 'http://localhost/index.html',
  moduleNameMapper: {
    '^.+\\.(css|scss)$': 'identity-obj-proxy',
    '@seleniumhq/side-model': '<rootDir>/packages/side-model',
    '@seleniumhq/side-code-export': '<rootDir>/packages/side-code-export',
  },
  setupFilesAfterEnv: ['./scripts/jest/test.config.js'],
  testMatch: ['**/packages/**/__test?(s)__/**/*.spec.[jt]s?(x)'],
  testPathIgnorePatterns: ['/node_modules/'],
  transform: {
    '^.+\\.jsx?$': 'babel-jest',
    '^.+\\.tsx?$': 'ts-jest',
  },
  testEnvironment: 'jsdom',

tsconfig.json in the root selenium-ide directory by adding esModuleInterop, baseUrl and paths to compilerOptions like so:

"compilerOptions": {
    "strictNullChecks": false,
    "inlineSourceMap": true,
    "inlineSources": true,
    "esModuleInterop": true,
    "baseUrl": ".",
    "paths": {
      "@seleniumhq/side-model": ["./packages/side-model"],
      "@seleniumhq/side-code-export": ["./packages/side-code-export"]
    }

But I’m still unable to successfully run tests for any of the exporters, whether it’s the exporter I’m building, or existing exporters, they all display the same issues with loading dependant packages.

Any clue on what might be the issue would me much appreciated.

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Comments: 15 (15 by maintainers)

Most upvoted comments

Hi @toddtarsi,

Appreciate your work, I’ve reviewed your PR and I’m not entirely sure if we understood each other. I’m building a new javascript exporter, so it’s not that I want to use an existing exporter and modify its output - this might work if there was a generic javascript exporter - I’m looking to build an exporter from scratch.

Absolutely. I wanted to make sure using side-code-export to instrument your export format was easy and pleasant to work with. That’s all this demonstrates: taking a suite, adding custom commands, and exporting with custom commands to a language.

Also, since this is all gone now, how do I modify emitTest and emitSuite outputs if I had to include some custom behaviour (additional output)?

Nothing here is gone. I swapped in a default on those because it makes life easier for me and dries out the code. Feel free to write your LanguageEmitter however you choose (and please use the types, they’re there to enhance your QOL)

I might be missing something though … maybe I’m not fully understand your changes and the side-example-suite package intention?

Just to give you an idea of what I’m building is a new version of this package but relying on Selenium v4 api and generating Selenium v4 compatible format (output) along with some extra output for a new environment the generated scripts are going to run in.

Absolutely, and all of that sounds very reasonable. So, you see how I’m using that file to import and slightly modify an output format? Instead, just export your output format from there and things would work. You could just copy one of the code-export packages if you want to start from somewhere. Let me know if any of this doesn’t make sense.

Not a problem at all @toddtarsi I’m a maintainer of a couple of repos and I totally understand, I regretted I had suggested a timeline 😅

I’ll be digging into the codebase anyways, feel free to provide additional info when/if you have time, also, I don’t want to make too much of an off topic here. Appreciate your continued support 🥇

@matewilk - I am so sorry. I wish I could have gotten to this last night, but I was driving back from SeleniumConf until 10 or so. I will get into this this weekend. My objective would be to do one code-export via the package, and rename the package if needed to side-code-export because that would make the bin file match the package name, and then it should be pretty easy to do from CLI.

If you want to see what it should look like from non-CLI consumption, the bin file is kind of the most basic wrapper I currently have to provide:

https://github.com/SeleniumHQ/selenium-ide/blob/trunk/packages/side-code-export/src/bin.ts