Skip to content

Instantly share code, notes, and snippets.

@rstacruz
rstacruz / README.md
Last active April 23, 2024 00:19
Setting up Jest with ESM

Setting up Jest with ESM

Here are some different ways on how to set up Jest to support ESM. This applies for Jest v25, Node v13, and Babel v7.

Method A: Native Node.js support

Node v14 and Jest v26 support ESM natively with the --experimental-vm-modules flag.

Install cross-env:

@lsapan
lsapan / vue-tests-mocha-webpack-with-coverage.md
Created December 27, 2019 21:53
Setting up Vue tests (with coverage) for mocha and Webpack

Setting up Vue tests (with coverage) for mocha and Webpack

There are seemingly a few incompatibilities with Vue and Istanbul/nyc at the moment, making it a bit difficult to set up proper coverage reporting for Vue files. Thankfully, there's a relatively easy way to fix that!

This will walk you through everything you need to do to add tests and coverage reporting to your vue-cli based project.

  1. Install dependencies for testing and coverage reporting

    yarn add -D @vue/cli-plugin-unit-mocha @vue/test-utils istanbul-instrumenter-loader nyc
    
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active May 18, 2024 15:38
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@hopsoft
hopsoft / db.rake
Last active May 6, 2024 14:00
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
@dbi
dbi / edit.html.mustache
Created May 4, 2011 09:31
Rails form helper for mustache spike/proof of concept
<!-- A scaffolded edit view converted to mustache -->
<h1>Editing post</h1>
{{#form}}
{{#errors?}}
<div id="error_explanation">
<h2>{{error_header}}</h2>
</div>
<ul>