Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { render, Component } from 'preact/compat';
import React, { createElement, render, Component } from 'preact/compat';
import { setupScratch, teardown } from '../../../test/_util/helpers';
import { act } from 'preact/test-utils';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { setupScratch, teardown } from '../../../test/_util/helpers';
import React, {
render,
createElement,
Fragment,
createContext,
Component,
useState,
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { hydrate } from 'preact/compat';
import React, { createElement, hydrate } from 'preact/compat';
import { setupScratch, teardown } from '../../../test/_util/helpers';
import { vi } from 'vitest';

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { render, hydrate, useState } from 'preact/compat';
import React, { createElement, render, hydrate, useState } from 'preact/compat';
import ReactDOMServer from 'preact/compat/server';
import { setupScratch, teardown } from '../../../test/_util/helpers';
import { act } from 'preact/test-utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import 'preact/debug';
import { setupScratch, teardown } from '../../../test/_util/helpers';
import { vi } from 'vitest';

/** @jsx createElement */

// This test is not part of component-stack.test.js to avoid it being
// transpiled with '@babel/plugin-transform-react-jsx-source' enabled.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import 'preact/debug';
import { vi } from 'vitest';
import { setupScratch, teardown } from '../../../test/_util/helpers';

/** @jsx createElement */

describe('component stack', () => {
/** @type {HTMLDivElement} */
let scratch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { forwardRef, createPortal } from 'preact/compat';
import { vi } from 'vitest';

const h = createElement;
/** @jsx createElement */

describe('debug compat', () => {
let scratch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { act } from 'preact/test-utils';
import { setupScratch, teardown } from '../../../test/_util/helpers';
import { vi } from 'vitest';

/** @jsx createElement */

describe('debug with hooks', () => {
let scratch;
let errors = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import {
} from '../../../test/_util/helpers';
import { vi } from 'vitest';

/** @jsx createElement */

describe('debug with suspense', () => {
/** @type {HTMLDivElement} */
let scratch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import 'preact/debug';
import { setupScratch, teardown } from '../../../test/_util/helpers';
import { vi } from 'vitest';

/** @jsx createElement */

describe('debug options', () => {
/** @type {HTMLDivElement} */
let scratch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { setupRerender } from 'preact/test-utils';
import { vi } from 'vitest';

const h = createElement;
/** @jsx createElement */

describe('debug', () => {
/** @type {HTMLDivElement} */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { createElement, Component } from 'preact';
import { serializeVNode } from '../../src/debug';

/** @jsx createElement */

describe('serializeVNode', () => {
it("should prefer a function component's displayName", () => {
function Foo() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import { setupScratch, teardown } from '../../../test/_util/helpers';
import 'preact/debug';
import { vi } from 'vitest';

/** @jsx createElement */

describe('Hook argument validation', () => {
/**
* @param {string} name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { useState } from 'preact/hooks';
import { addHookName } from 'preact/devtools';
import { vi } from 'vitest';

/** @jsx createElement */

describe('addHookName', () => {
/** @type {HTMLDivElement} */
let scratch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import {
import { scheduleEffectAssert } from '../_util/useEffectUtil';
import { vi } from 'vitest';

/** @jsx createElement */

describe('combinations', () => {
/** @type {HTMLDivElement} */
let scratch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { act } from 'preact/test-utils';
import { setupScratch, teardown } from '../../../test/_util/helpers';
import { useEffect } from 'preact/hooks';

/** @jsx createElement */

describe('errorInfo', () => {
/** @type {HTMLDivElement} */
let scratch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { useErrorBoundary, useLayoutEffect, useState } from 'preact/hooks';
import { setupRerender } from 'preact/test-utils';
import { vi } from 'vitest';

/** @jsx createElement */

describe('errorBoundary', () => {
/** @type {HTMLDivElement} */
let scratch, rerender;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import {
} from 'preact/hooks';
import { vi } from 'vitest';

/** @jsx createElement */

describe('hook options', () => {
/** @type {HTMLDivElement} */
let scratch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { createElement, render } from 'preact';
import { setupScratch, teardown } from '../../../test/_util/helpers';
import { useCallback } from 'preact/hooks';

/** @jsx createElement */

describe('useCallback', () => {
/** @type {HTMLDivElement} */
let scratch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { setupScratch, teardown } from '../../../test/_util/helpers';
import { useContext, useEffect, useState } from 'preact/hooks';
import { vi } from 'vitest';

/** @jsx createElement */

describe('useContext', () => {
/** @type {HTMLDivElement} */
let scratch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { setupScratch, teardown } from '../../../test/_util/helpers';
import { useDebugValue, useState } from 'preact/hooks';
import { vi } from 'vitest';

/** @jsx createElement */

describe('useDebugValue', () => {
/** @type {HTMLDivElement} */
let scratch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { useEffectAssertions } from './useEffectAssertions';
import { scheduleEffectAssert } from '../_util/useEffectUtil';
import { vi } from 'vitest';

/** @jsx createElement */

describe('useEffect', () => {
/** @type {HTMLDivElement} */
let scratch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { createElement, render } from 'preact';
import { setupScratch, teardown } from '../../../test/_util/helpers';
import { vi } from 'vitest';

/** @jsx createElement */

// Common behaviors between all effect hooks
export function useEffectAssertions(useEffect, scheduleEffectAssert) {
/** @type {HTMLDivElement} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { setupRerender } from 'preact/test-utils';
import { render as rts } from 'preact-render-to-string';
import { setupScratch, teardown } from '../../../test/_util/helpers';

/** @jsx createElement */

describe('useId', () => {
/** @type {HTMLDivElement} */
let scratch, rerender;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { useImperativeHandle, useRef, useState } from 'preact/hooks';
import { setupRerender } from 'preact/test-utils';
import { vi } from 'vitest';

/** @jsx createElement */

describe('useImperativeHandle', () => {
/** @type {HTMLDivElement} */
let scratch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import { useEffectAssertions } from './useEffectAssertions';
import { useLayoutEffect, useRef, useState } from 'preact/hooks';
import { vi } from 'vitest';

/** @jsx createElement */

describe('useLayoutEffect', () => {
/** @type {HTMLDivElement} */
let scratch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { useMemo, useState } from 'preact/hooks';
import { act } from 'preact/test-utils';
import { vi } from 'vitest';

/** @jsx createElement */

describe('useMemo', () => {
/** @type {HTMLDivElement} */
let scratch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { createElement, render, createContext } from 'preact';
import { setupScratch, teardown } from '../../../test/_util/helpers';
import { useReducer, useEffect, useContext } from 'preact/hooks';

/** @jsx createElement */

describe('useReducer', () => {
/** @type {HTMLDivElement} */
let scratch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { createElement, render } from 'preact';
import { setupScratch, teardown } from '../../../test/_util/helpers';
import { useRef } from 'preact/hooks';

/** @jsx createElement */

describe('useRef', () => {
/** @type {HTMLDivElement} */
let scratch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { vi } from 'vitest';
import { useState, useContext, useEffect } from 'preact/hooks';
import { setupScratch, teardown } from '../../../test/_util/helpers';

/** @jsx createElement */

describe('useState', () => {
/** @type {HTMLDivElement} */
let scratch;
Expand Down
2 changes: 1 addition & 1 deletion jsconfig-lint.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"skipLibCheck": true,
"noEmit": true,
"typeRoots": ["./node_modules/@types", "./types"]
"typeRoots": ["./node_modules/@types", "./node_modules", "./types"]
},
"include": [
"src/**/*",
Expand Down
3 changes: 2 additions & 1 deletion jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
},
"target": "es5",
"noEmit": true,
"skipLibCheck": false
"skipLibCheck": false,
"types": ["vitest/globals"]

@rschristian rschristian Sep 28, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Was this not an issue for everyone else btw? In every single file (beyond our TS tests, which also set this in their tsconfig.json files) I get hundreds of Cannot fine name 'describe'/'expect'. Do you need to install type definitions...

I'd almost have to assume folks are using other editor setups than me as it makes mine light up like a christmas tree without this

},
"exclude": ["**/node_modules/**", "**/dist/**", "coverage", "demo"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { act } from 'preact/test-utils';
import { setupScratch, teardown } from '../../../test/_util/helpers';
import { vi } from 'vitest';

/** @jsx createElement */

// IE11 doesn't support `new Event()`
function createEvent(name) {
if (typeof Event == 'function') return new Event(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { options, createElement, render, Component } from 'preact';
import { teardown, setupRerender } from 'preact/test-utils';
import { vi } from 'vitest';

/** @jsx createElement */

describe('setupRerender & teardown', () => {
/** @type {HTMLDivElement} */
let scratch;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { createElement, cloneElement, createRef } from 'preact';

/** @jsx createElement */

describe('cloneElement', () => {
it('should clone components', () => {
function Comp() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
} from '../_util/helpers';
import { vi } from 'vitest';

/** @jsx createElement */
const h = createElement;

function getAttributes(node) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { createElement, render, Component, Fragment } from 'preact';
import { setupScratch, teardown } from '../_util/helpers';
import { vi } from 'vitest';

/** @jsx createElement */

describe('context', () => {
let scratch;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import {
import { setupScratch, teardown } from '../_util/helpers';
import { vi } from 'vitest';

/** @jsx createElement */

describe('createContext', () => {
let scratch;
let rerender;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { createElement, render, Component } from 'preact';
import { setupScratch, teardown } from '../_util/helpers';
import { vi } from 'vitest';

/** @jsx createElement */

const runSuite = typeof customElements == 'undefined' ? xdescribe : describe;

runSuite('customised built-in elements', () => {
Expand Down
2 changes: 0 additions & 2 deletions test/browser/events.test.js → test/browser/events.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import {
} from '../_util/helpers';
import { vi } from 'vitest';

/** @jsx createElement */

describe('event handling', () => {
let scratch, proto;

Expand Down
1 change: 0 additions & 1 deletion test/browser/focus.test.js → test/browser/focus.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { createElement, render, Component, Fragment, hydrate } from 'preact';
import { setupScratch, teardown } from '../_util/helpers';
import { div, span, input as inputStr, h1, h2 } from '../_util/dom';

/** @jsx createElement */
/* eslint-disable react/jsx-boolean-value */

describe('focus', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { setupScratch, teardown } from '../_util/helpers';
import { span, div, ul, ol, li, section } from '../_util/dom';
import { logCall, clearLog, getLog } from '../_util/logCall';

/** @jsx createElement */
/* eslint-disable react/jsx-boolean-value */

describe('Fragment', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import { getDomSibling } from '../../src/component';
import { setupScratch, teardown } from '../_util/helpers';

/** @jsx createElement */

describe('getDomSibling', () => {
/** @type {HTMLDivElement} */
let scratch;
Expand All @@ -20,7 +18,7 @@

it('should find direct sibling', () => {
render(
<div>

Check failure on line 21 in test/browser/getDomSibling.test.jsx

View workflow job for this annotation

GitHub Actions / Build & Test / Build & Test

test/browser/getDomSibling.test.jsx > getDomSibling > should find direct sibling

TypeError: Cannot read properties of undefined (reading '_children') ❯ test/browser/getDomSibling.test.jsx:21:3
<div>A</div>
<div>B</div>
</div>,
Expand All @@ -28,7 +26,7 @@
);
let vnode = getRoot(scratch)._children[0]._children[0];
expect(getDomSibling(vnode)).to.equalNode(scratch.firstChild.childNodes[1]);
});

Check failure on line 29 in test/browser/getDomSibling.test.jsx

View workflow job for this annotation

GitHub Actions / Build & Test / Build & Test

test/browser/getDomSibling.test.jsx > getDomSibling > should find direct text node sibling

TypeError: Cannot read properties of undefined (reading '_children') ❯ test/browser/getDomSibling.test.jsx:29:2

it('should find direct text node sibling', () => {
render(
Expand All @@ -36,13 +34,13 @@
<div>A</div>B
</div>,
scratch
);

Check failure on line 37 in test/browser/getDomSibling.test.jsx

View workflow job for this annotation

GitHub Actions / Build & Test / Build & Test

test/browser/getDomSibling.test.jsx > getDomSibling > should find nested text node sibling

TypeError: Cannot read properties of undefined (reading '_children') ❯ test/browser/getDomSibling.test.jsx:37:2
let vnode = getRoot(scratch)._children[0]._children[0];
expect(getDomSibling(vnode)).to.equalNode(scratch.firstChild.childNodes[1]);
});

it('should find nested text node sibling', () => {
render(

Check failure on line 43 in test/browser/getDomSibling.test.jsx

View workflow job for this annotation

GitHub Actions / Build & Test / Build & Test

test/browser/getDomSibling.test.jsx > getDomSibling > should find text node sibling with placeholder

TypeError: Cannot read properties of undefined (reading '_children') ❯ test/browser/getDomSibling.test.jsx:43:2
<div>
<Fragment>
<div>A</div>
Expand All @@ -59,7 +57,7 @@
render(<div>A{null}B</div>, scratch);
let vnode = getRoot(scratch)._children[0]._children[0];
expect(getDomSibling(vnode)).to.equalNode(scratch.firstChild.childNodes[1]);
});

Check failure on line 60 in test/browser/getDomSibling.test.jsx

View workflow job for this annotation

GitHub Actions / Build & Test / Build & Test

test/browser/getDomSibling.test.jsx > getDomSibling > should find sibling with placeholder

TypeError: Cannot read properties of undefined (reading '_children') ❯ test/browser/getDomSibling.test.jsx:60:2

it('should find sibling with placeholder', () => {
render(
Expand Down Expand Up @@ -91,7 +89,7 @@
expect(getDomSibling(vnode)).to.equalNode(scratch.firstChild.childNodes[1]);
});

it('should find sibling in parent', () => {

Check failure on line 92 in test/browser/getDomSibling.test.jsx

View workflow job for this annotation

GitHub Actions / Build & Test / Build & Test

test/browser/getDomSibling.test.jsx > getDomSibling > should find sibling with nested placeholder

TypeError: Cannot read properties of undefined (reading '_children') ❯ test/browser/getDomSibling.test.jsx:92:4
render(
<div>
<Fragment>
Expand All @@ -101,7 +99,7 @@
</div>,
scratch
);
let vnode = getRoot(scratch)._children[0]._children[0]._children[0];

Check failure on line 102 in test/browser/getDomSibling.test.jsx

View workflow job for this annotation

GitHub Actions / Build & Test / Build & Test

test/browser/getDomSibling.test.jsx > getDomSibling > should find sibling in parent

TypeError: Cannot read properties of undefined (reading '_children') ❯ test/browser/getDomSibling.test.jsx:102:31
expect(getDomSibling(vnode)).to.equalNode(scratch.firstChild.childNodes[1]);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import { ul, li, div } from '../_util/dom';
import { logCall, clearLog, getLog } from '../_util/logCall';
import { vi } from 'vitest';

/** @jsx createElement */

describe('hydrate()', () => {
/** @type {HTMLElement} */
let scratch;
Expand Down
2 changes: 0 additions & 2 deletions test/browser/keys.test.js → test/browser/keys.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { logCall, clearLog, getLog } from '../_util/logCall';
import { div } from '../_util/dom';
import { vi } from 'vitest';

/** @jsx createElement */

describe('keys', () => {
/** @type {HTMLDivElement} */
let scratch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { createElement, render, Component, Fragment } from 'preact';
import { setupScratch, teardown } from '../../_util/helpers';
import { vi, expect } from 'vitest';

/** @jsx createElement */

describe('Lifecycle methods', () => {
/* eslint-disable react/display-name */

Expand Down
Loading
Loading