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

Add types to @types/qunit that are needed for ember-qunit #63805

Merged

Conversation

gitKrystan
Copy link
Contributor

@gitKrystan gitKrystan commented Jan 5, 2023

Adds and fixes types used by ember-qunit in emberjs/ember-qunit#994

Add optional source property to Assert.pushResult argument:
https://github.com/qunitjs/qunit/blob/fc278e8c0d7e90ec42e47b47eee1cc85c9a9efaf/src/test.js#L572

Make QUnit.config.testTimeout optional:
https://github.com/qunitjs/qunit/blob/fc278e8c0d7e90ec42e47b47eee1cc85c9a9efaf/src/test.js#L733
ember-qunit sets testTimeout to null in "dev mode." Additionally, code surrounding testTimeout seems to assume it can be something other than a number.

Add QUnit.config.timeout type: https://github.com/qunitjs/qunit/blob/fc278e8c0d7e90ec42e47b47eee1cc85c9a9efaf/src/test.js#L752

Add QUnit.urlParams type:
https://github.com/qunitjs/qunit/blob/fc278e8c0d7e90ec42e47b47eee1cc85c9a9efaf/src/html-reporter/html.js#L256
https://github.com/qunitjs/qunit/blob/fc278e8c0d7e90ec42e47b47eee1cc85c9a9efaf/test/reporter-urlparams.js#L11

Adds Module interface:
https://github.com/qunitjs/qunit/blob/fc278e8c0d7e90ec42e47b47eee1cc85c9a9efaf/src/module.js#L45
I included only the properties needed for ember-qunit but left some commented out properties I discovered during my code reading but didn't need. Do you want to make any of these public?

Adds Test interface:
https://github.com/qunitjs/qunit/blob/fc278e8c0d7e90ec42e47b47eee1cc85c9a9efaf/src/test.js#L23
I included only the properties needed for ember-qunit but left some commented out properties I discovered during my code reading but didn't need. Do you want to make any of these public?

Select one of these and delete the others:

If changing an existing definition:

  • Provide a URL to documentation or source code which provides context for the suggested changes:
  • If this PR brings the type definitions up to date with a new version of the JS library, update the version number in the header.

@typescript-bot
Copy link
Contributor

typescript-bot commented Jan 5, 2023

@gitKrystan Thank you for submitting this PR!

This is a live comment which I will keep updated.

1 package in this PR

Code Reviews

Because you edited one package and updated the tests (👏), I can help you merge this PR once someone else signs off on it.

You can test the changes of this PR in the Playground.

Status

  • ✅ No merge conflicts
  • ✅ Continuous integration tests have passed
  • ✅ Most recent commit is approved by type definition owners or DT maintainers

All of the items on the list are green. To merge, you need to post a comment including the string "Ready to merge" to bring in your changes.


Diagnostic Information: What the bot saw about this PR
{
  "type": "info",
  "now": "-",
  "pr_number": 63805,
  "author": "gitKrystan",
  "headCommitOid": "6da98c46b675850da61b0a008851ae34dc4c0d87",
  "mergeBaseOid": "a79ac14faaee3afff32af2c799f05ad217182bcf",
  "lastPushDate": "2023-01-05T18:42:09.000Z",
  "lastActivityDate": "2023-01-05T19:41:01.000Z",
  "mergeOfferDate": "2023-01-05T19:36:58.000Z",
  "mergeRequestDate": "2023-01-05T19:41:01.000Z",
  "mergeRequestUser": "Krinkle",
  "hasMergeConflict": false,
  "isFirstContribution": false,
  "tooManyFiles": false,
  "hugeChange": false,
  "popularityLevel": "Popular",
  "pkgInfo": [
    {
      "name": "qunit",
      "kind": "edit",
      "files": [
        {
          "path": "types/qunit/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/qunit/test/global-test.ts",
          "kind": "test"
        }
      ],
      "owners": [
        "waratuman",
        "mike-north",
        "sechel",
        "chriskrycho",
        "dfreeman",
        "jamescdavis",
        "Krinkle"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Popular"
    }
  ],
  "reviews": [
    {
      "type": "approved",
      "reviewer": "Krinkle",
      "date": "2023-01-05T19:36:12.000Z",
      "isMaintainer": false
    }
  ],
  "mainBotCommentID": 1371609292,
  "ciResult": "pass"
}

@typescript-bot typescript-bot added the Popular package This PR affects a popular package (as counted by NPM download counts). label Jan 5, 2023
@typescript-bot
Copy link
Contributor

🔔 @waratuman @mike-north @sechel @chriskrycho @dfreeman @jamescdavis @Krinkle — please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

@typescript-bot typescript-bot added the The CI failed When GH Actions fails label Jan 5, 2023
@typescript-bot
Copy link
Contributor

@gitKrystan The CI build failed! Please review the logs for more information.

Once you've pushed the fixes, the build will automatically re-run. Thanks!

Note: builds which are failing do not end up on the list of PRs for the DT maintainers to review.

@Krinkle
Copy link
Contributor

Krinkle commented Jan 5, 2023

@@ -256,7 +256,7 @@ interface Config {
+ timeout?: ReturnType<typeof setTimeout> | null;

This is an internal undocumented property. I'd prefer we silence the use in ember-qunit for the time being instead of possibly encouraging use elsewhere by documenting it for TypeScript.

In QUnit 3, I intend to make two major changes ref qunitjs/qunit#1483:

  1. Internally, I'd like to remove the complexity around having QUnit act asynchronously for an asyncronous test, yet sometimes have nothing in its state that waits for the test to finish (e.g. no timeout or promise). This leads to bugs at times which would improve stability if we remove it. This by itself could be resolved by changing the default timeout to Infinity or MAX_SAFE_INTEGER, but see point two.
  2. Externally, I'd like to improve dev experience by providing a default timeout of, say, 3 seconds. It can be raised of course per-test or globally.

For the ember-qunit, I see a number of ways forward:

  • Set the per-test timeout to MAX_SAFE_INTEGER while the test is paused, and undo it with another assert.timeout() when resuming.
  • More idiomatic, perhaps, we have assert.async() nowadays. This lets you explicitly wait for a callback or promise that ember-qunit controls. You could potentially use that same one during unpause.

@typescript-bot typescript-bot removed the The CI failed When GH Actions fails label Jan 5, 2023
@typescript-bot typescript-bot added the The CI failed When GH Actions fails label Jan 5, 2023
@typescript-bot
Copy link
Contributor

@gitKrystan The CI build failed! Please review the logs for more information.

Once you've pushed the fixes, the build will automatically re-run. Thanks!

Note: builds which are failing do not end up on the list of PRs for the DT maintainers to review.

@typescript-bot typescript-bot removed the The CI failed When GH Actions fails label Jan 5, 2023
@gitKrystan
Copy link
Contributor Author

@@ -256,7 +256,7 @@ interface Config {
+ timeout?: ReturnType<typeof setTimeout> | null;

This is an internal undocumented property. I'd prefer we silence the use in ember-qunit for the time being instead of possibly encouraging use elsewhere by documenting it for TypeScript.

Sounds good. I removed it from this PR and updated my ember-qunit PR accordingly.

Any thoughts on the rest of the stuff? Specifically, is there anything else on the Test and Module interfaces you'd like to make public while I'm at it?

@Krinkle
Copy link
Contributor

Krinkle commented Jan 5, 2023

@gitKrystan Beyond what is on https://api.qunitjs.com/extension/, I'd consider the Module and Test objects fully internal. They're fairly stable, but to ease maintenance of the TS definitions I'd recommend against adding much detail here beyond that helps you right now.

@typescript-bot typescript-bot added Owner Approved A listed owner of this package signed off on the pull request. Self Merge This PR can now be self-merged by the PR author or an owner labels Jan 5, 2023
@Krinkle
Copy link
Contributor

Krinkle commented Jan 5, 2023

@gitKrystan If you're interested, perhaps you'd like to look at adding test.each() to the TS defs next?

I have an old PR at #62328 but can't find the time to get it in mergable state. It's a relatively new and well-liked features, but lacking TS definitions at the moment.

@Krinkle
Copy link
Contributor

Krinkle commented Jan 5, 2023

Ready to merge

@typescript-bot typescript-bot merged commit 75c4ee2 into DefinitelyTyped:master Jan 5, 2023
@gitKrystan gitKrystan deleted the qunit-types-for-ember-qunit branch January 6, 2023 00:07
@sukima
Copy link

sukima commented Jul 16, 2024

Hey everyone! it has been well over a year. What is blocking QUnit.test.each()? It is very unfortunate many developers are unable to use this feature in qunit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Owner Approved A listed owner of this package signed off on the pull request. Popular package This PR affects a popular package (as counted by NPM download counts). Self Merge This PR can now be self-merged by the PR author or an owner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants