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

Sinon transformer doesn't support cjs #544

Closed
marklai1998 opened this issue Jun 20, 2023 · 4 comments · Fixed by #576
Closed

Sinon transformer doesn't support cjs #544

marklai1998 opened this issue Jun 20, 2023 · 4 comments · Fixed by #576
Labels

Comments

@marklai1998
Copy link

Hello, I'm trying to use this tool to transform existing Sinon code to Jest
But the transformer skips every file I throw at it.

I see the test case for Sinon transformer is using ESM while all other is Cjs
Its nice to support ESM, but cjs should be the majority of the user here

@skovhus
Copy link
Owner

skovhus commented Jun 20, 2023

Can you add an example file here, it should work for both?

@marklai1998
Copy link
Author

test.spec.js

const { expect } = require("chai");
const sinon = require("sinon");

const featureFlagSdk = require("./file");

describe("test", () => {
  describe("createCustomIcon", () => {
    before(() => {
      sinon.stub(featureFlagSdk, "evaluate").resolves(true);
    });

    it("should get file url and create icon for zeus", async () => {
      expect(true).to.be.deep.equal(true);
    });
  });
});

My settings:

? Which parser do you want to use? Babel
? Which test library would you like to migrate from? Sinon
? Are you using the global object for assertions (i.e. without requiring them) Yes, and I'm not afraid of false positive transformations
? Will you be using Jest on Node.js as your test runner? Yes, use the globals provided by Jest (recommended)

@skovhus
Copy link
Owner

skovhus commented Jun 20, 2023

Thanks! Would you be up for fixing this? I hope it should be pretty straightforward as the other transformers handles this correctly (I believe).

I suggest adding a test case in https://github.com/skovhus/jest-codemods/blob/main/src/transformers/sinon.test.ts and take it from there.

@skovhus skovhus added the bug label Jun 20, 2023
@marklai1998
Copy link
Author

Thanks! Would you be up for fixing this? I hope it should be pretty straightforward as the other transformers handles this correctly (I believe).

I suggest adding a test case in https://github.com/skovhus/jest-codemods/blob/main/src/transformers/sinon.test.ts and take it from there.

just tried for a while, I don't think I'm able to do it, most of the type def is gone and I don't have the knowledge foundation jscodeshift

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

Successfully merging a pull request may close this issue.

2 participants