Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for using consumers jest config #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AdilBhayani
Copy link
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
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);
}


const defaultArgs = ['--watch'];

export const test = async (args: string[] = defaultArgs) => {
const jestBin = binPath('jest');
const configPath = path.resolve(__dirname, '../../jest.config.js');

const upperJestPath = '../../../../jest.config.js';
Copy link
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.

None yet

3 participants