Skip to content

Instantly share code, notes, and snippets.

@ng-the-engineer
ng-the-engineer / dummy.test.ts
Created January 17, 2021 16:56
Code snippet: Dummy test.ts
import { sum } from "./dummy";
test("Dummy unit test", () => {
const actual = sum(1, 2);
expect(actual).toBe(3);
});
@ng-the-engineer
ng-the-engineer / dummy.ts
Created January 17, 2021 16:54
Code snippet: dummy ts function
export const sum = (a: number, b: number) => {
return a + b;
};
@ng-the-engineer
ng-the-engineer / README.md
Created January 17, 2021 16:49
Code snippet: Failed unit test
➜  jest-with-typescript git:(main) ✗ npx jest
 FAIL  source/dummy.test.ts
  ✕ Dummy unit test (3 ms)

...

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots: 0 total
@ng-the-engineer
ng-the-engineer / dummy.test.ts
Last active January 17, 2021 16:53
Code snippet: dummy unit test
test("Dummy unit test", () => {
const actual = null; // not implemented yet
expect(actual).toBe(1);
});
@ng-the-engineer
ng-the-engineer / README.md
Created January 17, 2021 16:44
Code snippet: Jest test not defined
➜  jest-with-typescript git:(main) ✗ npx jest
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In /Users/anthonyng/Repo/jest-with-typescript
  2 files checked.
  testMatch: **/__tests__/**/*.[jt]s?(x), **/?(*.)+(spec|test).[tj]s?(x) - 0 matches
  testPathIgnorePatterns: /node_modules/ - 2 matches
  testRegex:  - 0 matches
Pattern: - 0 matches
@ng-the-engineer
ng-the-engineer / README.md
Created September 21, 2020 09:33
Run redis official container
1. Redis

Redis is used to support the message queue. Run below command to run the offical Redis container

$ docker run --name my-redis-container -p 6379:6379 -d redis

(Optional) To access Redis, check this gist

@ng-the-engineer
ng-the-engineer / README.md
Last active September 30, 2020 03:55
Install Redis-cli

Redis-cli

Redis-cli allows you to access Redis instance. Run below command to install.

brew tap ringohub/redis-cli

brew update && brew doctor
@ng-the-engineer
ng-the-engineer / README.md
Last active September 25, 2020 16:47
Setup ES2020

Install @babel/cli, @babel/core, @babel/node, and @babel/preset-env

yarn add --dev @babel/cli @babel/core @babel/node @babel/preset-env

Create .babelrc

{
@ng-the-engineer
ng-the-engineer / README.md
Last active October 5, 2020 08:06
ES2015 babel setup

ES6 babel setup

  1. Install Babel
$ npm install -D babel-cli babel-preset-es2015
  1. Create .babelrc in root folder
@ng-the-engineer
ng-the-engineer / READMe.md
Created July 26, 2020 17:54
Create model in local DynamoDB example

Create model programmatically

  1. Create a Json file mymodel.json for a basic model
{
  "TableName": "YOUR_TABLE_NAME",
  "KeySchema": [
    {
 "AttributeName": "KEY_COLUMN_NAME",