How to ignore streamlit-component-lib for transform with jest tests? SyntaxError: Unexpected token 'export'

I created a custom component and want to write tests for the front end part.

I got

SyntaxError: Unexpected token 'export'

and tried to exclude streamlit-component-lib from transform. I tried both, with command line argument and custom jest.config.js but did not get it working.

module.exports = {
    moduleDirectories: ["node_modules"],
    moduleFileExtensions: ["js", "ts", "tsx", "json", "node"],
    roots: ["src", "test"],
    testPathIgnorePatterns: ["<rootDir>/node_modules/",],
    testEnvironment: 'jest-environment-jsdom',
    transform: {
       '^.+\\.jsx?$': 'babel-jest',
       '^.+\\.tsx?$': 'ts-jest',
     },
    transformIgnorePatterns: [
      '<rootDir>/node_modules/(?!' +
          [
            'streamlit-component-lib',
          ].join('|') +
      ')'
    ]
};

Also see

=> Has someone else already solved this issue?

I also tried to mock streamlit-component-lib but that is also not that easy.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.