Skip to content

Commit 07450a1

Browse files
atkAlex Lohr
andauthored
package updates and fixes (#20)
Co-authored-by: Alex Lohr <alex.lohr@goto.com>
1 parent 37b3fd7 commit 07450a1

7 files changed

Lines changed: 7947 additions & 4409 deletions

File tree

package-lock.json

Lines changed: 7917 additions & 4381 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "solid-testing-library",
3-
"version": "0.3.0",
3+
"version": "0.4.0",
44
"description": "Simple and complete Solid testing utilities that encourage good testing practices.",
55
"main": "./dist/index.cjs",
66
"module": "./dist/index.mjs",
@@ -51,26 +51,27 @@
5151
"report:coverage": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"
5252
},
5353
"dependencies": {
54-
"@testing-library/dom": "^7.29.4"
54+
"@testing-library/dom": "^8.19.0"
5555
},
5656
"devDependencies": {
57-
"@babel/cli": "^7.17.6",
58-
"@babel/core": "^7.17.5",
59-
"@babel/preset-env": "^7.16.11",
60-
"@babel/preset-typescript": "7.16.7",
61-
"@testing-library/jest-dom": "^5.16.2",
62-
"@testing-library/user-event": "^13.5.0",
63-
"@types/jest": "^27.4.1",
64-
"babel-jest": "^27.5.1",
65-
"babel-preset-solid": "^1.3.6",
57+
"@babel/cli": "^7.19.3",
58+
"@babel/core": "^7.19.6",
59+
"@babel/preset-env": "^7.19.4",
60+
"@babel/preset-typescript": "7.18.6",
61+
"@testing-library/jest-dom": "^5.16.5",
62+
"@testing-library/user-event": "^14.4.3",
63+
"@types/jest": "^29.2.1",
64+
"babel-jest": "^29.2.2",
65+
"babel-preset-solid": "^1.6.1",
6666
"coveralls": "^3.1.1",
67-
"jest": "^27.5.1",
68-
"prettier": "^2.5.1",
69-
"pretty-format": "^27.5.1",
67+
"jest": "^29.2.2",
68+
"jest-environment-jsdom": "^29.2.2",
69+
"prettier": "^2.7.1",
70+
"pretty-format": "^29.2.1",
7071
"rimraf": "^3.0.2",
7172
"solid-jest": "^0.2.0",
72-
"solid-js": "^1.3.8",
73-
"typescript": "^4.5.5"
73+
"solid-js": "^1.6.1",
74+
"typescript": "^4.8.4"
7475
},
7576
"peerDependencies": {
7677
"solid-js": ">=1.0.0"

src/__tests__/basic.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ test("findByTestId returns the element", async () => {
3030
expect(await screen.findByTestId("foo")).toBe(ref);
3131
});
3232

33-
test("userEvent triggers createEffect calls", () => {
33+
test("userEvent triggers createEffect calls", async () => {
3434
const cb = jest.fn();
3535

3636
function Counter() {
@@ -46,7 +46,7 @@ test("userEvent triggers createEffect calls", () => {
4646
} = render(() => <Counter />);
4747

4848
cb.mockClear();
49-
userEvent.click(buttonNode! as Element);
49+
await userEvent.click(buttonNode! as Element);
5050
expect(buttonNode).toHaveTextContent("1");
5151
expect(cb).toHaveBeenCalledTimes(1);
5252
});

src/__tests__/debug.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ test("allows same arguments as prettyDOM", () => {
4343
expect(console.log).toHaveBeenCalledTimes(1);
4444
// @ts-ignore
4545
expect(console.log.mock.calls[0]).toMatchInlineSnapshot(`
46-
Array [
46+
[
4747
"<div>
4848
...",
4949
]

src/__tests__/events.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,14 @@ eventTypes.forEach(({ type, events, elementType, init }) => {
154154
});
155155
});
156156

157-
test("onInput works", () => {
157+
test("onInput works", async () => {
158158
const handler = jest.fn();
159159

160160
const {
161161
container: { firstChild: input }
162162
} = render(() => <input type="text" onInput={handler} />);
163163

164-
userEvent.type(input! as Element, "a");
164+
await userEvent.type(input! as Element, "a");
165165

166166
expect(handler).toHaveBeenCalledTimes(1);
167167
});

src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ function render(ui: Ui, options: Options = {}): Result {
4545
// they're passing us a custom container or not.
4646
mountedContainers.add({ container, dispose });
4747

48+
const queryHelpers = getQueriesForElement(baseElement, queries)
49+
4850
return {
4951
container,
5052
baseElement,
@@ -53,7 +55,7 @@ function render(ui: Ui, options: Options = {}): Result {
5355
? el.forEach(e => console.log(prettyDOM(e, maxLength, options)))
5456
: console.log(prettyDOM(el, maxLength, options)),
5557
unmount: dispose,
56-
...getQueriesForElement(baseElement, queries)
58+
...queryHelpers
5759
} as Result;
5860
}
5961

src/types.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { JSX } from "solid-js";
2-
import type { Queries, BoundFunction, prettyFormat } from "@testing-library/dom";
2+
import { queries } from "@testing-library/dom";
3+
import type { Queries, BoundFunctions, prettyFormat } from "@testing-library/dom";
34

45
export interface Ref {
56
container: HTMLElement;
@@ -11,21 +12,19 @@ export type Ui = () => JSX.Element;
1112
export interface Options {
1213
container?: HTMLElement;
1314
baseElement?: HTMLElement;
14-
queries?: Queries;
15+
queries?: Queries & typeof queries;
1516
hydrate?: boolean;
1617
}
1718

18-
export type Extra = { [P in keyof Queries]: BoundFunction<Queries[P]> };
19-
2019
export type DebugFn = (
2120
baseElement?: HTMLElement | HTMLElement[],
2221
maxLength?: number,
2322
options?: prettyFormat.OptionsReceived
2423
) => void;
2524

26-
export type Result = {
25+
export type Result = BoundFunctions<typeof queries> & {
2726
container: HTMLElement;
2827
baseElement: HTMLElement;
2928
debug: DebugFn;
3029
unmount: () => void;
31-
} & Extra;
30+
} ;

0 commit comments

Comments
 (0)