
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
⚠️ This is a beta release – expect frequent updates and possible breaking changes.
TWD (Testing Web Development) is a tool designed to help integrating testing while developing web applications. It aims to streamline the testing process and make it easier for developers to write and run tests as they build their applications.
Right now we only support React, but we plan to add support for other frameworks in the future.
You can install TWD via npm:
# with npm
npm install twd-js
# with yarn
yarn add twd-js
# with pnpm
pnpm add twd-js
Add the our React Sidebar component to your application:
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import { TWDSidebar } from 'twd-js'
import router from './routes.ts'
import { RouterProvider } from 'react-router'
createRoot(document.getElementById('root')!).render(
<StrictMode>
<RouterProvider router={router} />
<TWDSidebar />
</StrictMode>,
)
Then, create test files with the twd.test.ts
or any extension you want. For example:
// src/app.twd.test.ts
import { describe, it, twd } from "twd-js";
beforeEach(() => {
console.log("Reset state before each test");
});
describe("App interactions", () => {
it("clicks the button", async () => {
twd.visit("/"); // Visit the root URL
const btn = await twd.get("button");
btn.click();
const message = await twd.get("#message");
// have.text
const haveText = await twd.get("#message");
haveText.should("have.text", "Hello");
});
});
After you create your test you need to load them in your application. You can do this by creating a loadTests.ts
file and importing all your test files there:
// src/loadTests.ts
import "./app.twd.test";
import "./another-test-file.twd.test";
// Import other test files here
Or if you're using vite you can use Vite's import.meta.glob
to automatically import all test files in a directory:
// This automatically imports all files ending with .twd.test.ts
const modules = import.meta.glob("./**/*.twd.test.ts", { eager: true });
// You don't need to export anything; simply importing this in App.tsx
// will cause the test files to execute and register their tests.
Then, import the loadTests.ts
file in your main application file (e.g., main.tsx
or App.tsx
):
import './loadTests' // Import test files
Finally, run your application and open the TWD sidebar to see and run your tests.
You can check the examples directory for more usage scenarios.
FAQs
Test While Developing (TWD) - in-browser testing
We found that twd-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.