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

testing-unit-ts doesn't work with current package.json dependencies #1645

Closed
madappa-sharath opened this issue Jun 21, 2023 · 3 comments · Fixed by #1644
Closed

testing-unit-ts doesn't work with current package.json dependencies #1645

madappa-sharath opened this issue Jun 21, 2023 · 3 comments · Fixed by #1644
Assignees
Labels
kind/bug Some behavior is incorrect or out of spec language/javascript resolution/fixed This issue was fixed
Milestone

Comments

@madappa-sharath
Copy link

What happened?

I have unit tests that test the output of components. These outputs are inputs to the constructor and not those generated by cloud providers. These tests have started failing after an upgrade to pulumi npm package. The output promises don't resolve in the newer versions of '@pulumi/pulumi' dependency.

These failures go away if I pin the version of '@pulumi/pulumi' package. These can be reproduced on the unit-testing guides in pulumi website as well. If you run the tests in https://github.com/pulumi/examples/tree/master/testing-unit-ts on a clean install, the tests will fail.

output from the example on latest version:

  Infrastructure
    1) "before all" hook in "Infrastructure"


  0 passing (4s)
  1 failing

  1) Infrastructure
       "before all" hook in "Infrastructure":
     Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/foo/workspace/pulumi-bug/ec2tests.ts)

Expected Behavior

The promises should resolve and tests should be able to access the values.

Steps to reproduce

  1. copy https://github.com/pulumi/examples/tree/master/testing-unit-ts/mocha into a directory
  2. run npm install
  3. run npx mocha -r ts-node/register ec2tests.ts
  4. tests should fail.

Output of pulumi about

CLI
Version 3.72.2
Go Version go1.20.5
Go Compiler gc

Plugins
NAME VERSION
aws 5.41.0
nodejs unknown

Host
OS darwin
Version 13.4
Arch x86_64

This project is written in nodejs: executable='/Users//.nvm/versions/node/v18.14.2/bin/node' version='v18.14.2'

Backend
Name pulumi.com
URL https://app.pulumi.com/
User
Organizations

Dependencies:
NAME VERSION
mocha 9.2.2
ts-node 9.1.1
typescript 4.9.5
@pulumi/aws 5.41.0
@pulumi/pulumi 3.72.2
@types/mocha 9.1.1
@types/node 13.13.52

Additional context

These tests work fine if I pin the version of '@pulumi/pulumi' to '3.64.0' and '@pulumi/aws' to '5.36.0'. These versions are from my package-lock.json before I tried the update. Bug is in one of the versions above this.

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).


@madappa-sharath madappa-sharath added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Jun 21, 2023
@justinvp
Copy link
Member

@madappa-sharath, I'm unable to repro with https://github.com/pulumi/examples/tree/master/testing-unit-ts after installing fresh dependencies with npm install:

[~/go/src/github.com/pulumi/examples/testing-unit-ts/mocha (master)]$ npx mocha -r ts-node/register ec2tests.ts


  Infrastructure
    #server
      ✔ must have a name tag
      ✔ must not use userData (use an AMI instead)
    #group
      ✔ must not open port 22 (SSH) to the Internet


  3 passing (161ms)
$ pulumi about
CLI
Version      3.73.0
Go Version   go1.20.5
Go Compiler  gc

Plugins
NAME    VERSION
aws     5.41.0
nodejs  unknown

Host
OS       darwin
Version  12.6.6
Arch     arm64

This project is written in nodejs: executable='/Users/justin/.nvm/versions/node/v19.1.0/bin/node' version='v19.1.0'

Backend
Name           pulumi.com
URL            https://app.pulumi.com/justin-pulumi-corp
User           justin-pulumi-corp
Organizations  justin-pulumi-corp, pulumi

Dependencies:
NAME            VERSION
typescript      4.9.5
@pulumi/aws     5.41.0
@pulumi/pulumi  3.73.0
@types/mocha    9.1.1
@types/node     13.13.52
mocha           9.2.2
ts-node         9.1.1

Can you try again using the latest version of @pulumi/pulumi: 3.73.0?

@justinvp justinvp added awaiting-feedback Blocked on input from the author language/javascript and removed needs-triage Needs attention from the triage team labels Jun 25, 2023
@madappa-sharath
Copy link
Author

@justinvp did not work for me. Here's the output from the latest version.

$ npx mocha -r ts-node/register ec2tests.ts


  Infrastructure
    1) "before all" hook in "Infrastructure"


  0 passing (5s)
  1 failing

  1) Infrastructure
       "before all" hook in "Infrastructure":
     Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/poof/workspace/pulumi-bug/ec2tests.ts)
$ pulumi about
CLI          
Version      3.74.0
Go Version   go1.20.5
Go Compiler  gc

Plugins
NAME    VERSION
aws     5.41.0
nodejs  unknown

Host     
OS       darwin
Version  13.4.1
Arch     x86_64

This project is written in nodejs: executable='/Users/poof/.nvm/versions/node/v19.1.0/bin/node' version='v19.1.0'

Backend        
Name           pulumi.com
URL            https://app.pulumi.com/smadappa
User           smadappa
Organizations  smadappa

Dependencies:
NAME            VERSION
@types/mocha    9.1.1
@types/node     13.13.52
mocha           9.2.2
ts-node         9.1.1
typescript      4.9.5
@pulumi/aws     5.41.0
@pulumi/pulumi  3.74.0

Pulumi locates its logs in /var/folders/9_/cc18mwvs58776qv_l3d1mk3w0000gp/T/ by default
warning: Failed to get information about the current stack: No current stack

apologies for the close/re-open churn. I got confused by the option next to the comment button.

@mikhailshilkov mikhailshilkov added needs-triage Needs attention from the triage team and removed awaiting-feedback Blocked on input from the author labels Jun 5, 2024
@justinvp justinvp removed the needs-triage Needs attention from the triage team label Jun 8, 2024
@justinvp justinvp self-assigned this Jun 8, 2024
@justinvp justinvp added this to the 0.106 milestone Jun 8, 2024
@justinvp
Copy link
Member

justinvp commented Jun 8, 2024

I just tried this again and ran into a new error, but after updating package.json to the latest versions:

{
    "name": "test-unit-ts",
    "devDependencies": {
        "mocha": "^10.4.0",
        "ts-node": "^10.9.2",
        "typescript": "^5.4.5"
    },
    "dependencies": {
        "@pulumi/aws": "^6.39.0",
        "@pulumi/pulumi": "^3.119.0",
        "@types/mocha": "^10.0.6",
        "@types/node": "^13.1.8"
    }
}

... it worked as expected after running npm install:

$ npx mocha -r ts-node/register ec2tests.ts


  Infrastructure
    #server
      ✔ must have a name tag
      ✔ must not use userData (use an AMI instead)
    #group
      ✔ must not open port 22 (SSH) to the Internet


  3 passing (203ms)

I've gone ahead and opened #1644

At this point, I believe this is just an issue with the example, so transferring the issue to that repo.

@justinvp justinvp transferred this issue from pulumi/pulumi Jun 8, 2024
@justinvp justinvp changed the title Component output promises don't resolve in unit tests after pulumi version upgrade. Was working before testing-unit-ts doesn't work with current package.json dependencies Jun 8, 2024
justinvp added a commit that referenced this issue Jun 8, 2024
I tried running the example locally with `npx mocha -r ts-node/register
ec2tests.ts` and ran into an error. However, after upgrading the
dependencies to the latest versions, everything works as expected.

Updated the CI workflows to use the same `npx mocha ...` command we
mention in
https://github.com/pulumi/examples/blob/master/testing-unit-ts/mocha/README.md,
and updated those to run on the current active LTS version of Node (20).

Fixes #1645
@pulumi-bot pulumi-bot added the resolution/fixed This issue was fixed label Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec language/javascript resolution/fixed This issue was fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants