demo-typescript-jest

Demonstration of TypeScript and Jest testing

https://github.com/joelparkerhenderson/demo-typescript-jest

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (7.9%) to scientific vocabulary
Last synced: 10 months ago · JSON representation ·

Repository

Demonstration of TypeScript and Jest testing

Basic Info
  • Host: GitHub
  • Owner: joelparkerhenderson
  • Language: TypeScript
  • Default Branch: main
  • Size: 36.1 KB
Statistics
  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created about 2 years ago · Last pushed about 1 year ago
Metadata Files
Readme Citation

README.md

Demo TypeScript Jest

Demonstration of:

  • TypeScript

  • Jest testing

Start

Initialize:

sh mkdir demo && cd $_

Add git

Run:

git init git remote add origin git@github.com:example/demo.git git branch -M main echo "node_modules/" >> .gitignore git add -A git commit -m "Init" git push -u origin main

Verify:

sh git status

Result:

stdout … Your branch is up to date with 'origin/main'.

Add NPM

Run:

sh npm init -y

Verify:

sh npm --version

Output:

stdout 10.5.2

Add TypeScript

Run:

sh npm install typescript --save-dev

Verify:

sh tsc -v

Output:

stdout Version 5.4.5

Initialize:

sh tsc --init

Review:

sh cat tsconfig.json

Output:

stdout Created a new tsconfig.json with: target: es2016 module: commonjs strict: true esModuleInterop: true skipLibCheck: true forceConsistentCasingInFileNames: true

Create code

Create source code

Run:

sh mkdir src && cd $_ echo 'console.log("hello world")' > index.ts tsc index.ts node index.js

Output:

stdout hello world

Commit:

sh git add index.{js,ts} git commit -m "Add hello world"

Add Jest for testing

Run:

sh npm install jest ts-jest @types/jest --save-dev

Add a script to your file package.json:

json "scripts": { "test": "jest" }

Create file jest.config.js:

ts module.exports = { preset: "ts-jest", testEnvironment: "node", };

Create source file src/sum.ts:

ts export function sum(a: number, b: number): number { return a + b; }

Create corresponding test file tests/sum.test.ts:

```ts import { sum } from "../src/sum";

describe("Math functions", () => { it("should sum two numbers correctly", () => { expect(sum(1, 2)).toEqual(3); }); }); ```

Run:

sh npm test

Output:

```stdout PASS tests/sum.test.ts Math functions ✓ should sum two numbers correctly (1 ms)

Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: 0.653 s Ran all test suites. ```

Owner

  • Name: Joel Parker Henderson
  • Login: joelparkerhenderson
  • Kind: user
  • Location: California

Software developer. Technology consultant. Creator of GitAlias.com, NumCommand.com, SixArm.com, and many open source projects.

Citation (CITATION.cff)

cff-version: 1.2.0
title: Demo TypeScript Jest
message: >-
  If you use this work and you want to cite it,
  then you can use the metadata from this file.
type: software
authors:
  - given-names: Joel Parker
    family-names: Henderson
    email: joel@joelparkerhenderson.com
    affiliation: joelparkerhenderson.com
    orcid: 'https://orcid.org/0009-0000-4681-282X'
identifiers:
  - type: url
    value: 'https://github.com/joelparkerhenderson/demo-typescript-jest/'
    description: Demo TypeScript Jest
repository-code: 'https://github.com/joelparkerhenderson/demo-typescript-jest/'
abstract: >-
  Demo TypeScript Jest
license: See license file

GitHub Events

Total
  • Push event: 1
Last Year
  • Push event: 1

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 2
  • Total Committers: 1
  • Avg Commits per committer: 2.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 1
  • Committers: 1
  • Avg Commits per committer: 1.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Joel Parker Henderson j****l@j****m 2
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: about 1 year ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Dependencies

package-lock.json npm
  • 284 dependencies
package.json npm
  • @types/jest ^29.5.12 development
  • jest ^29.7.0 development
  • ts-jest ^29.1.2 development
  • typescript ^5.4.5 development