Skip to content

Updated to be typescript compatable#1

Open
Lee-Ashmore wants to merge 1 commit into
kajabi-mike:mainfrom
Lee-Ashmore:main
Open

Updated to be typescript compatable#1
Lee-Ashmore wants to merge 1 commit into
kajabi-mike:mainfrom
Lee-Ashmore:main

Conversation

@Lee-Ashmore

Copy link
Copy Markdown

Migrate Gilded Rose to TypeScript + Add Mocha Test Suite

Summary

This PR converts the Gilded Rose repository from JavaScript to TypeScript and introduces a Mocha/Chai test suite with a custom assertion plugin.


Changes

TypeScript Migration

  • Renamed all .js source files to .ts
  • Added strict TypeScript configuration via tsconfig.json
  • Added @types/node, typescript, and ts-node/tsx as dev dependencies
  • Updated package.json main entry and build script to reflect .ts source and compiled .js output in dist/

Test Infrastructure

  • Installed and configured Mocha as the test runner with Chai as the assertion library
  • Added .mocharc.json to configure tsx as the TypeScript loader, test file glob, and setup file loading
  • Added test and test:watch scripts to package.json

Custom Chai Plugin

  • Created src/test/plugins/inventory-check.ts — a reusable Chai plugin exposing the toMatchSellInAndQuality(sellIn, quality) assertion for validating item state after a tick()
  • Created src/test/setup.ts — registers the plugin globally via chai.use() so all test files get the assertion automatically
  • Added TypeScript type augmentation (declare global) so the custom method typechecks correctly across the project

Test Coverage

  • Added src/gilded-rose.test.ts covering all current item types:
    • Normal Item
    • Aged Brie
    • Sulfuras (Legendary)
    • Backstage Passes
  • Conjured Item tests are present but skipped (describe.skip) pending implementation

How to Run

# Run tests once
npm test

# Run in watch mode during development
npm run test:watch

# Build TypeScript
npm run build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant