Skip to content
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: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
},
"license": "MIT",
"author": "Ryan Carniato",
"maintainers": ["Alex Lohr"],
"homepage": "https://github.com/solidjs/solid-testing-library#readme",
"repository": {
"type": "git",
Expand Down Expand Up @@ -43,11 +44,12 @@
"scripts": {
"prepublishOnly": "npm run build",
"build": "tsup src/index.ts --format esm,cjs --dts --clean",
"typecheck": "tsc --noEmit; tsc --noEmit --project src/__tests__/tsconfig.json",
"test": "vitest",
"test:watch": "npm test --watch",
"test:coverage": "npm test -- --coverage",
"setup": "npm install && npm run validate",
"validate": "npm run test:coverage && npm run build",
"validate": "npm run typecheck && npm run test:coverage && npm run build",
"report:coverage": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"
},
"dependencies": {
Expand Down
8 changes: 8 additions & 0 deletions src/__tests__/basic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,11 @@ test("calls to hydrate will run createEffects", () => {

expect(cb).toHaveBeenCalledTimes(1);
});

test("queries should not return elements outside of the container", () => {
const { container, getAllByText } = render(() => <div>Some text...</div>);
const falseContainer = document.createElement("p");
falseContainer.textContent = "Some text...";
container.parentNode!.insertBefore(falseContainer, getAllByText("Some text...")[0].parentNode);
expect(getAllByText("Some text...")[0] === container.childNodes[0]).toBe(true);
});
3 changes: 2 additions & 1 deletion src/__tests__/events.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Dynamic } from "solid-js/web";
import { render, fireEvent } from "..";
import userEvent from "@testing-library/user-event";
import type { Mock } from "vitest";

const eventTypes = [
{
Expand Down Expand Up @@ -129,7 +130,7 @@ const eventTypes = [
}
];

function event(el: HTMLElement, name: string, spy: vi.Mock) {
function event(el: HTMLElement, name: string, spy: Mock) {
el.addEventListener(name, spy);
}

Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/stopwatch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { screen, render } from "..";
function StopWatch() {
const [lapse, setLapse] = createSignal(0);
const [running, setRunning] = createSignal(false);
let timer: number;
let timer: ReturnType<typeof setInterval>;

const handleRunClick = () => {
if (running()) {
Expand Down
7 changes: 7 additions & 0 deletions src/__tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"types": ["vitest/globals", "@testing-library/jest-dom"]
},
"include": ["./*.tsx"]
}
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function render(ui: Ui, options: Options = {}): Result {
// they're passing us a custom container or not.
mountedContainers.add({ container, dispose });

const queryHelpers = getQueriesForElement(baseElement, queries)
const queryHelpers = getQueriesForElement(container, queries)

return {
container,
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"outDir": "./dist",
"module": "commonjs"
},
"include": ["src"],
"include": ["src/index.ts", "src/types.ts"],
}