Deadcode elimination via running end-to-end tests.

Overview

About

Deadcode elimination via running end-to-end tests.

Sample project: DCE for threejs

Install

npm i -D ycw/e2edce

Usage

First, create a configuration file in project root

Then, config package.json

{ 
  "scripts": {
    "build": "e2edce e2edce.config.js"
  }
}

Finally, run npm run build to build artifacts

  • index.build.js (min)
  • index.build.js.gz (min + gzipped)

Configuration File

e2edce.config.js

export default {
  // --- required ---
  configs: [ // array of configs
    {
      // --- required ---
      input: 'src/index.js', // path to entry
      output: 'index.build.js', // path to output file
      test: 'e2e/test.js', // path to test file 
      // --- optional ---
      compress: true, // compress? 
      mangle: true, // mangle?
      minify: true, // trim whitespaces?
      debug: false, // create a debug build?
      port: 8081, // dev server port
      headless: true, // run tests in headless browser?
    }
  ],
  // --- optional ---
  setup: async() => {}, // run once before processing
  teardown: async() => {}, // run once after processing
  resolve: async() => {}, // custom module resolve
}

Test File

e2e/test.js

Export a async fn or an object

export default async (page) => {
  await page.goto('http://localhost:8081', { waitUntil: 'networkidle' })
  // ...
}
export default {
  // --- required ---
  test: async () => {
    await page.goto('http://localhost:8081', { waitUntil: 'networkidle' })
  },
  // --- optional ---
  inject: () => {..}
}
  • page is a https://playwright.dev/docs/api/class-page

  • inject, a fn to be run at the end of input file.

    We could add mocks inside inject() to directly cover certain code branches instead of writing complex e2e tests inside test()

You might also like...

Awesome-Books project uses practical tests for JavaScript/Html and CSS functions.

Awesome-Books project uses practical tests for JavaScript/Html and CSS functions.

Awesome-Books project uses practical tests for JavaScript/Html and CSS functions. The project presents a basic website that allows users to add/remove books from a list.

Jan 31, 2022

Example Serverless DynamoDB integration tests using Jest, TypeScript and the AWS CDK

Example Serverless DynamoDB integration tests using Jest, TypeScript and the AWS CDK

serverless dynamodb integration tests 🚀 Example Serverless DynamoDB integration tests using Jest, TypeScript and the AWS CDK Introduction How to inte

Nov 4, 2022

A Jest runner that runs tests directly in bare Node.js, without virtualizing the environment.

jest-light-runner A Jest runner that runs tests directly in bare Node.js, without virtualizing the environment. Comparison with the default Jest runne

Dec 12, 2022

Command line tool that automatically migrates tests from protractor to playwright.

Protractor to Playwright migration tool This tool is designed to automatically migrate code from Protractor to Playwright. It is inspired by the "Migr

Nov 20, 2022

Export Cypress Tests from Google Chrome DevTools' Recorder

@cypress/chrome-recorder This repo provides tools to export Cypress Tests from Google Chrome DevTools' Recordings Installation $ npm install -g @cypre

Dec 20, 2022

Debug your Jest tests. Effortlessly.🛠🖼

Debug your Jest tests. Effortlessly.🛠🖼

Jest Preview Debug your Jest tests. Effortlessly. 🛠 🖼 Try Jest Preview Online. No downloads needed! Why jest-preview When writing tests using Jest,

Jan 4, 2023

Boilerplate starter template for a new TON blockchain project - FunC contracts, JS tests, compilation and deployment scripts

TON Starter Template - Contracts Starter template for a new TON project - FunC contracts, JS tests, compilation and deployment scripts Overview This p

Dec 17, 2022

Completely free TS/JS one-file source code snippets with tests, which can be copied to avoid extra dependencies (contributions welcome).

TinySource Completely free TS/JS one-file source code snippets with tests, which can be copied to avoid extra dependencies (contributions welcome). Sn

Jan 3, 2023

Notes, challenge resolutions, and applications of the Grokking Algorithms book content with unit tests

Notes, challenge resolutions, and applications of the Grokking Algorithms book content with unit tests

Grokking Algorithms Statements Branches Functions Lines Notes, challenge resolutions, and applications of the Grokking Algorithms book content Index F

Aug 14, 2022
Releases(v0.2.7)
Owner
null
Jugglr is a tool for managing test data and running tests with a dedicated database running in a Docker container.

Jugglr Jugglr is a tool for managing test data and running tests with a lightweight, dedicated database. Jugglr enables developers, testers, and CI/CD

OSLabs Beta 74 Aug 20, 2022
Example-browserstack-reporting - This repository contains an example of running Selenium tests and reporting BrowserStack test results, including full CI pipeline integration.

BrowserStack reporting and Selenium test result example This repository contains an example of running Selenium tests and reporting BrowserStack test

Testmo 1 Jan 1, 2022
Running webdriverio in docker containers so you can easily add tests to your CI.

WebDriverIO tests in Docker Running WebdriverIO tests in a docker container allows you to easily add tests to your CI. About This project uses the aut

Promenade 6 Dec 3, 2022
Access the internals of React components from Cypress end-to-end tests

cypress-react-app-actions Access the internals of React components from Cypress end-to-end tests Read Access React Components From Cypress E2E Tests a

Gleb Bahmutov 5 May 12, 2022
A simple application to estuding tests end-to-end in Angular with Cypress

Conhecimento sobre testes End to End (ponta a ponta) Sobre o Cypress: Testes feitos do sistema para ver como um usuário se comportaria, esses testes é

Kauã Werle 3 Jun 15, 2022
🤗 A CLI for running Stable Diffusion locally via a REST API on an M1/M2 MacBook

Stable Diffusion REST API A CLI for running Stable Diffusion locally via a REST API on an M1/M2 MacBook Pre-requisites An M1/M2 MacBook Homebrew Pytho

Yuan Qing Lim 74 Dec 26, 2022
Runs various integration tests for the composable picasso parachain.

Picasso Integration Tester Picasso Integration Tester is a collection of different implementation tests for the Picasso Polkadot Parachain. Installati

Dominik Roth 0 Jan 11, 2022
This is a test parser which can automatically parse the tests in from websites like codeforces, codechef, atcoder etc.

✔ Sublime test parser This is a test parser which can automatically parse the tests in from websites like codeforces, codechef, atcoder etc. See how i

Prakhar Rai 15 Aug 6, 2022