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

Add support for running Typescript tests directly (without transpiling). #42

Merged
merged 10 commits into from
Aug 17, 2022

Conversation

prudhvi22
Copy link
Contributor

fixes #33

@prudhvi22 prudhvi22 requested a review from garg3133 August 4, 2022 07:19
@garg3133
Copy link
Member

garg3133 commented Aug 4, 2022

Actually, this is not what is to be done. Let's break it into a few steps:

  • Step 1: When a new TS project is created, we create a new tsconfig.json file for the users (in setupTypeScript() function) where we just copy the TS file already present in assets folder. Instead of this, we should now use tsc --init command to generate a new tsconfig.json file in the root dir.
  • Step 2: Coming to the issue raised by Andrei, the first part of it is to allow users to run the ts tests directly instead of compiling them first. For this, we need to do three things:
  1. Create a nightwatch/tsconfig.json file (check if nightwach/tsconfig.json or tsconfig.nightwatch.json is not already present) which ts-node will use to transpile ts files before running them. So, this file will contain only the necessary settings. This is not to be generated by using tsc --init but by editing the assets/tsconfig.json file and then copying it to nightwatch. (The code for this will be placed in setupTypescript() itself as it is a part of setting up Typescript.
  2. Install ts-node as a devDependency. This is to be done in identifyPackagesToInstall() function itself.
  3. Since we no longer require this.otherInfo.tsOutDir now (as we don't need to pre-compile ts test files now before running them), we can safely remove it and make necessary changes at other places accordingly. But this is not an easy task and would need my involvement, so for now instead of reading the outDir property from tsconfig.json file in setupTypescript(), we can just set this.otherInfo.tsOutDir to '' and it should work fine. Just test it out.
  • Step 3: Coming to the second part of issue TypeScript setup: move tsconfig.json to nightwatch/tsconfig.json #33, the structure of examples need to be modified as suggested by Andrei. So, if the testsLocation provided by the user is empty or non-existent, you can copy the examples to the testsLocation itself, so that they can be used by user as boilerplate. Otherwise, copy all the examples to nightwatch folder.

Copy link
Member

@garg3133 garg3133 left a comment

Choose a reason for hiding this comment

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

Just a few comments, otherwise looks good to me! You can start working on the examples restructure in a separate branch (created from main branch) as there's a very little conflict, if any, between the two works.

@garg3133 garg3133 changed the base branch from main to v1.2.0 August 10, 2022 17:04
- Fixed linting errors.
- Corrected post-setup instructions for TypeScript.
- Removed code for editing `test` script in package.json.
@garg3133 garg3133 changed the base branch from v1.2.0 to main August 16, 2022 07:59
@garg3133 garg3133 changed the title Added tsconfig file in nightwatch directory Add support for running Typescript tests directly (without transpiling). Aug 17, 2022
@garg3133 garg3133 changed the base branch from main to v1.2.0 August 17, 2022 06:21
Copy link
Member

@garg3133 garg3133 left a comment

Choose a reason for hiding this comment

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

LGTM!

@garg3133 garg3133 merged commit e362c2d into nightwatchjs:v1.2.0 Aug 17, 2022
garg3133 added a commit that referenced this pull request Sep 9, 2022
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.

TypeScript setup: move tsconfig.json to nightwatch/tsconfig.json
2 participants