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

chore: test types and warnings #4369

Merged
merged 2 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compat/test/browser/testUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ export function getSymbol(name, fallback) {
// eslint-disable-next-line
if (
Function.prototype.toString
.call(eval('Symbol.for'))
.call((0, eval)('Symbol.for'))
.match(/\[native code\]/)
) {
// Concatenate these string literals to prevent the test
// harness and/or Babel from modifying the symbol value.
// eslint-disable-next-line
out = eval('Sym' + 'bol.for("' + name + '")');
out = (0, eval)('Sym' + 'bol.for("' + name + '")');
Comment on lines -13 to +19
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silences this:

Warning: G] Using direct eval with a bundler is not recommended and may cause problems [direct-eval]

    compat/test/browser/testUtils.js:11:41:
      11 │ ...ction.prototype.toString.call(eval('Symbol.for')).match(/\[nati...
         ╵                                  ~~~~

  You can read more about direct eval and bundling here: https://esbuild.github.io/link/direct-eval

Warning: G] Using direct eval with a bundler is not recommended and may cause problems [direct-eval]

    compat/test/browser/testUtils.js:15:12:
      15 │       out = eval('Sym' + 'bol.for("' + name + '")');
         ╵             ~~~~

  You can read more about direct eval and bundling here: https://esbuild.github.io/link/direct-eval

Warning: G] Using direct eval with a bundler is not recommended and may cause problems [direct-eval]

    compat/test/browser/testUtils.js:11:41:
      11 │ ...ction.prototype.toString.call(eval('Symbol.for')).match(/\[nati...
         ╵                                  ~~~~

  You can read more about direct eval and bundling here: https://esbuild.github.io/link/direct-eval

Warning: G] Using direct eval with a bundler is not recommended and may cause problems [direct-eval]

    compat/test/browser/testUtils.js:15:12:
      15 │       out = eval('Sym' + 'bol.for("' + name + '")');
         ╵             ~~~~

  You can read more about direct eval and bundling here: https://esbuild.github.io/link/direct-eval

}
} catch (e) {}

Expand Down
47 changes: 41 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@
"@types/chai": "^4.1.2",
"@types/mocha": "^5.0.0",
"@types/node": "^14.14.10",
"@types/sinon": "^9.0.11",
"babel-plugin-istanbul": "^6.0.0",
"babel-plugin-transform-async-to-promises": "^0.8.15",
"babel-plugin-transform-rename-properties": "0.1.0",
Expand Down
2 changes: 1 addition & 1 deletion test/browser/getDomSibling.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { setupScratch, teardown } from '../_util/helpers';
/** @jsx createElement */

describe('getDomSibling', () => {
/** @type {import('../../src/internal').PreactElement} */
/** @type {HTMLDivElement} */
let scratch;

const getRoot = dom => dom._children;
Expand Down
17 changes: 14 additions & 3 deletions test/extensions.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
declare module Chai {
export interface Assertion {
equalNode(node: Node | null, message?: string): void;
declare global {
namespace Chai {
interface Assertion {
equalNode(node: Node | null, message?: string): void;
called: Assertion;
calledOnce: Assertion;
calledTwice: Assertion;
calledWith(...args: any[]): Assertion;
calledWithMatch(...args: Record<string, unknown>[]): Assertion;
}
Comment on lines +4 to +9
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's still a few missing, but this should at least cut down on the number of squiggles.

}
var expect: Chai.ExpectStatic;
var sinon: Sinon;
}

export {};
Loading