Skip to content

Allow for using consumers jest config#23

Open
AdilBhayani wants to merge 1 commit into
masterfrom
Allow-using-own-jest-config
Open

Allow for using consumers jest config#23
AdilBhayani wants to merge 1 commit into
masterfrom
Allow-using-own-jest-config

Conversation

@AdilBhayani
Copy link
Copy Markdown
Collaborator

This PR allows the the consumer of this repo to specify a jest.config.js file in the root of their own repo. If it is present then it will be used. Otherwise we fallback to the jest.config.js which is present in this package.

I've tested this using yalc and https://github.com/AdilBhayani/Date-time-convertor.

import path from 'path';

export const checkFileExists = (resolutionPath: string) => {
if (existsSync(path.resolve(__dirname, resolutionPath))) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have a similar logic in src/utils/createFile.ts I'd recommend extracting that into own util and not using the sync version:

import { promisify } from 'util';
import {exists} from 'fs'

const existFile = (path: string) => {
  return promisify(fs.exists)(path);
}

Comment thread src/commands/test.ts
const jestBin = binPath('jest');
const configPath = path.resolve(__dirname, '../../jest.config.js');

const upperJestPath = '../../../../jest.config.js';
Copy link
Copy Markdown
Owner

@zzarcon zzarcon Mar 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also it will be nice to have a util to resolve user (or upper) path

import {consumerPath} from '../utils/'

const upperJestPath = consumerPath('jest.config.js');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants