Skip to content

Commit

Permalink
chore: add devcontainer (#12)
Browse files Browse the repository at this point in the history
* chore: add devcontainer

* chore: add dockerfile

* test: ignore electron in cypress

* test: fix broken test for report selector

* build: downgrade cypress to 13.8.1
  • Loading branch information
grantwforsythe committed May 6, 2024
1 parent 6ef199f commit ddabe23
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 7 deletions.
44 changes: 44 additions & 0 deletions .devcontainer/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# Compiled output
../dist
../tmp
../out-tsc
../bazel-out

# Node
../node_modules
../npm-debug.log
../yarn-error.log

# IDEs and editors
../.env
../.idea/
../.project
../.classpath
../.c9/
../*.launch
../.settings/
../*.sublime-workspace

# Visual Studio Code
../.vscode/*
../!.vscode/settings.json
../!.vscode/tasks.json
../!.vscode/launch.json
../!.vscode/extensions.json
../.history/*

# Miscellaneous
../.angular/cache
../.sass-cache/
../connect.lock
../coverage
../libpeerconnection.log
../testem.log
../typings
../cypress/downloads

# System files
../.DS_Store
../Thumbs.db
7 changes: 7 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM mcr.microsoft.com/devcontainers/typescript-node:1-20-bullseye

# Download and install Chrome
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list \
&& apt-get update \
&& apt-get install -y google-chrome-stable xvfb
50 changes: 50 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
{
"name": "Custom Reports for YNAB",

// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"build": {
"dockerfile": "Dockerfile"
},
// Load environment variables
"runArgs": ["--env-file=${localWorkspaceFolder}/.env"],

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers-contrib/features/angular-cli:2": {},
"ghcr.io/schlich/devcontainer-features/cypress:1": {}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [4200],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "npm install",

// TODO: Figure out a better way to handle this
// Reinstall Cypress
// https://github.com/cypress-io/cypress/issues/2610
"postStartCommand": "./node_modules/.bin/cypress install",

// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"esbenp.prettier-vscode",
"streetsidesoftware.code-spell-checker",
"editorconfig.editorconfig",
"rvest.vs-code-prettier-eslint",
"ms-vscode.vscode-typescript-next",
"angular.ng-template"
],
"settings": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
}
}
}

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
7 changes: 6 additions & 1 deletion cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { defineConfig } from 'cypress';

export default defineConfig({
e2e: {
// TODO: Set values based on environment
baseUrl: 'http://localhost:4200/',
setupNodeEvents(_on, config) {
return {
...config,
browsers: config.browsers.filter((b) => b.family === 'chromium' && b.name !== 'electron'),
};
},
},
});
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"@typescript-eslint/parser": "^7.2.0",
"autoprefixer": "^10.4.19",
"conventional-changelog-cli": "^4.1.0",
"cypress": "latest",
"cypress": "^13.8.1",
"eslint": "^8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-json": "^3.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/app/state/selectors/report.selectors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ describe('Report Selectors', () => {

const expected = transactions.reduce((date, transaction) => {
const transactionDate = new Date(transaction.date);
return transactionDate < date ? transactionDate : date;
return transactionDate <= date ? transactionDate : date;
}, new Date());

expect(result).toEqual(expected);
Expand Down

0 comments on commit ddabe23

Please sign in to comment.