Skip to content

Commit

Permalink
chore: added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio Moreno committed May 10, 2021
1 parent 25e9b64 commit f77b915
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: esbuild-jest

on: [push]
on: [push, pull_request]

jobs:
ubuntu-latest:
Expand All @@ -19,6 +19,7 @@ jobs:
- run: yarn
- run: yarn build
- run: yarn test
- run: yarn test:coverage
env:
CI: true
windows-latest:
Expand All @@ -37,6 +38,7 @@ jobs:
- run: yarn
- run: yarn build
- run: yarn test
- run: yarn test:coverage
env:
CI: true
macos-latest:
Expand All @@ -55,5 +57,6 @@ jobs:
- run: yarn
- run: yarn build
- run: yarn test
- run: yarn test:coverage
env:
CI: true
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
dist
.envrc
default.nix
default.nix
coverage
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"scripts": {
"postinstall": "yarn build",
"build": "ts-node ./tools/build.ts",
"test": "jest --clearCache && jest --detectOpenHandles"
"test": "jest --clearCache && jest --detectOpenHandles",
"test:coverage": "jest --clearCache && jest --coverage"
},
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const createTransformer = (options?: Options) => ({
const ext = getExt(filename), extName = extname(filename).slice(1)

// Caution: disabling this, can cause issues with inlineSnapshots since can't find the original line
const enableSourcemaps = options?.sourcemap || true
const enableSourcemaps = options?.sourcemap === false ? false : (options?.sourcemap || true)
const loader = (options?.loaders && options?.loaders[ext]
? options.loaders[ext]
: loaders.includes(extName) ? extName: 'text'
Expand All @@ -31,7 +31,7 @@ const createTransformer = (options?: Options) => ({
/// this will support the jest.mock
/// https://github.com/aelbore/esbuild-jest/issues/12
/// TODO: transform the jest.mock to a function using babel traverse/parse then hoist it
if (sources.code.indexOf("jest.mock(") >= 0 || opts?.instrument) {
if (sources.code.indexOf("jest.mock(") >= 0) {
const source = require('./transformer').babelTransform({
sourceText: content,
sourcePath: filename,
Expand Down

0 comments on commit f77b915

Please sign in to comment.