Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage in windows #2

Open
Limeyuzu opened this issue Apr 21, 2022 · 0 comments
Open

Usage in windows #2

Limeyuzu opened this issue Apr 21, 2022 · 0 comments

Comments

@Limeyuzu
Copy link

Hi, our team started using this package but later found that this doesn't work on windows machines (the team has a mix of windows and mac users). "Unable to expose method "then"" still shows up. On a windows machine I have tried running the tests in this package, which shows the same problem:

$ npm run test

> [email protected] test
> jest

 PASS  __tests__/index.ts
 FAIL  __tests__/request-promise.ts
  ● Test suite failed to run

    Unable to expose method "then"

      1 | import "request-promise";
    > 2 | import "request-promise-native";
        | ^
      3 |
      4 | it("should not fail miserably", () => {
      5 |     expect(true).toBeTruthy();

      at Object.plumbing.exposePromiseMethod (node_modules/request-promise-core/lib/plumbing.js:140:19)
      at Object.<anonymous> (__tests__/request-promise.ts:2:1)

Test Suites: 1 failed, 1 passed, 2 total
Tests:       4 passed, 4 total
Snapshots:   4 passed, 4 total
Time:        1.407s
Ran all test suites.

What I did was list out the 2 request-promise packages in jest.config.js which makes the tests pass:

const { defaults: tsjPreset } = require('ts-jest/presets');

module.exports = {
  preset: 'ts-jest',
  testEnvironment: 'node',
  transform: {
    ...tsjPreset.transform,
    'request-promise': '<rootDir>/dist/index.js',
    'request-promise-native': '<rootDir>/dist/index.js',
  },
  transformIgnorePatterns: ["/node_modules(?!/request-promise(-native)?)/"]
};

In our own code we have the transform section written similarly:

transform: {
  'request-promise': 'jest-transform-stealthy-require',
  'request-promise-native': 'jest-transform-stealthy-require',
},

Is there any issue with doing it this way? If not, I could create a pull request to update the config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant