CodeceptJS icon indicating copy to clipboard operation
CodeceptJS copied to clipboard

Feat/init codeceptjs with ts

Open kobenguyent opened this issue 3 years ago • 4 comments

Motivation/Description of the PR

  • This change gives you the possibility to init codeceptjs with typescript
thanh@Thanh-MBP14 automation % npx codeceptjs init

  Welcome to CodeceptJS initialization tool
  It will prepare and configure a test environment for you

Installing to /Users/thanh/Desktop/automation
? Is your project Typescript? yes
? Where are your tests located? ./*_test.js
? What helpers do you want to use? REST
? Where should logs, screenshots, and reports to be stored? ./output
? Do you want localization for tests? (See https://codecept.io/translation/) English (no localization)
Configure helpers...
? [REST] Endpoint of API you are going to test http://localhost:3000/api

Steps file created at ./steps_file.ts
Config created at /Users/thanh/Desktop/automation/codecept.conf.ts
Directory for temporary output files is already created at './output'
tsconfig.json already exists at /Users/thanh/Desktop/automation/tsconfig.json
jsconfig.json already exists at /Users/thanh/Desktop/automation/jsconfig.json
TypeScript Definitions provide autocompletion in Visual Studio Code and other IDEs
Definitions were generated in steps.d.ts

 Almost ready... Next step:
Creating a new test...
----------------------
? Feature which is being tested (ex: account, login, etc) 
? Filename of a test _test.js

Test for _test.js was created in /Users/thanh/Desktop/automation/_test.js

--
CodeceptJS Installed! Enjoy supercharged testing! 🤩
Find more information at https://codecept.io


--
Please install dependent packages locally: npm install --save-dev typescript ts-node

Type of change

  • [x] :rocket: New functionality

Checklist:

  • [x] Lint checking (Run npm run lint)
  • [x] Local tests are passed (Run npm test)

kobenguyent avatar Jul 19 '22 13:07 kobenguyent

I really like the idea but it should be improved:

Filename of a test _test.js

Tests should be created with ts extension As well as config should be codecept.conf.ts

Updated as requested.

kobenguyent avatar Aug 02 '22 08:08 kobenguyent

Not sure why the Run Unit tests / build (12.x) failed, I tried on my local, there is no issue

> [email protected] test:runner
> mocha test/runner --recursive



  CodeceptJS Timeouts
    ✓ should stop test when timeout exceeded (5434ms)
    ✓ should take --no-timeouts option (6307ms)
    ✓ should ignore timeouts if no timeout (1301ms)
    ✓ should use global timeouts if timeout is set (1283ms)
    ✓ should prefer step timeout (3376ms)
    ✓ should keep timeout with steps (392ms)


  6 passing (18s)


kobenguyent avatar Aug 02 '22 11:08 kobenguyent

Thanks, @PeterNgTr If you tried it and it works for you I'm merging

DavertMik avatar Aug 07 '22 16:08 DavertMik

Thanks, @PeterNgTr

If you tried it and it works for you I'm merging

Yeah, just gave it a try. Working like a charm.

kobenguyent avatar Aug 07 '22 16:08 kobenguyent