Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Gatsby starter with TypeScript, Jest, ESLint, Prettier, and GitLab-CI deployment to AWS S3 buckets.
Gatsby Typescript Jest Starter is a Boilerplate starter for Gatsby sites that wires up TypeScript, Jest, ESLint, Prettier, and optional GitLab-CI deployment to AWS S3 buckets. It was created by GitHub user denningk and is described in its README as a barebones Gatsby starter that also ships with a detailed guide for deploying your site to AWS S3, both manually and automatically.
This starter takes a new Gatsby project name as input and scaffolds a working site through the gatsby new my-gatsby-starter https://github.com/denningk/gatsby-starter-typescript-jest command. It runs on the Gatsby framework using Node.js and npm, and it outputs a static site in the /public folder after running gatsby build. The repository includes Gatsby's standard configuration files — gatsby-config.js, gatsby-node.js, gatsby-browser.js, and gatsby-ssr.js — so browser APIs, Node APIs, and server-side rendering APIs can be customized directly.
tsconfig.json is included, and the npm run type-check script lets you statically check your .tsx source files from the command line.jest.config.js, jest-preprocess.js for Babel transforms, and loadershim.js; an example snapshot test lives at /src/components/__tests__/header.tsx and verifies that the Header component renders correctly..eslintrc.js and .prettierrc are provided, with npm run lint for checking code style, plus an .editorconfig to keep consistent formatting across editors and IDEs./.github directory contains GitHub-specific files such as a pull request template, so contributors follow the same PR structure..gitlab-ci.yml defines build, test, and deploy stages with staging, QA, and production environments that deploy the generated /public folder to versioned AWS S3 buckets automatically.index.html and 404.html, and uploading the public folder by hand.__mocks__ directory provides a pattern for stubbing remote resources so tests stay fast and deterministic.http://localhost:8000/___graphql to experiment with data queries while editing src/pages/index.js.gatsby new command with the starter's repository URL to get a working site with TypeScript, Jest, ESLint, and Prettier preconfigured.npm run type-check, npm run lint, and npm test to catch type errors, style issues, and test failures locally.gatsby build, then upload everything inside the generated /public folder to an S3 bucket configured for static website hosting.master to deploy to QA, and create a release tag to deploy to production, all through the included GitLab-CI pipeline.First, create a new site with gatsby new my-gatsby-starter https://github.com/denningk/gatsby-starter-typescript-jest. Then gatsby develop starts the development server at http://localhost:8000, while npm test, npm run lint, and npm run type-check run the testing, linting, and type-checking tools. For deployment, gatsby build generates the static /public folder, which you either upload manually to S3 or let GitLab-CI upload based on the stages and triggers defined in .gitlab-ci.yml.
Pros:
__mocks__ directory give a concrete pattern for adding more component and snapshot tests.Cons:
.gitlab-ci.yml file is optional; the README says it should be deleted if you do not plan to use GitLab-CI.Yes. The starter ships with an MIT LICENSE file, and the README notes that Gatsby is licensed under the MIT license. You can use the starter for personal or commercial projects without paying a fee.
npm run type-check runs TypeScript type checking, npm run lint runs ESLint, and npm test runs Jest tests. For development, gatsby develop starts the server at http://localhost:8000, and gatsby build creates the static output in /public for deployment.
Yes, if you use GitLab-CI. The .gitlab-ci.yml triggers staging, QA, and production deploys on feature branch pushes, merges into master, and release tags of master respectively. You must first set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY as variables in GitLab's CI/CD settings.
The starter includes one example Jest snapshot test at /src/components/__tests__/header.tsx. It creates the Header component and verifies it renders correctly. The jest-preprocess.js file contains Babel settings that let Jest transform .tsx and .jsx files during testing.
