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

defineTest can not resolve async transform #516

Open
shiyangzhaoa opened this issue Jul 27, 2022 · 4 comments
Open

defineTest can not resolve async transform #516

shiyangzhaoa opened this issue Jul 27, 2022 · 4 comments

Comments

@shiyangzhaoa
Copy link

If the transform is async, defineTest run error, because the defineTest only support sync, output is promise
image

@ElonVolo
Copy link
Collaborator

Would you be able to up to github a temporary repository that reproduces the error?

@shiyangzhaoa
Copy link
Author

git clone jscodeshift

// sample/reverse-identifiers.js
function transformer(file, api) {
  const j = api.jscodeshift;

  return j(file.source)
    .find(j.Identifier)
    .replaceWith(
      p => j.identifier(p.node.name.split('').reverse().join(''))
    )
    .toSource();
}
// replace with async
function transformer(file, api) {
  const j = api.jscodeshift;

  const source = j(file.source)
    .find(j.Identifier)
    .replaceWith(
      p => j.identifier(p.node.name.split('').reverse().join(''))
    )
    .toSource();
    
   return Promise.resolve(source);
}

run yarn test

image

@michaelfaith
Copy link

Hitting up against this myself. It looks like the PR was closed out without a resolution?

@pierceray
Copy link

We just started running into this when the dependabot updated to @types/[email protected]. Has anyone managed to work around this?

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