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

Implement TypeScript support (closes #408) #1463

Merged
merged 24 commits into from
May 12, 2017
Merged

Conversation

inikulin
Copy link
Contributor

@inikulin inikulin commented May 4, 2017

This enables built-in compilation of .ts files and type definitions for TestCafe. You need to import 'testcafe'; (in case if you don't import e.g. Selector already) to enable typings, editor support and make test files compilable:

import `testcafe`;

fixture('My fixture');

test('My test', async t => {
});

Note that tagged template literal syntax is not available for fixture and page. Use function syntax instead.

To try code completion and API hints in VSCode run npm install @inikulin/testcafe and then import '@inikulin/testcafe' in your test file.

\cc @AlexanderMoskovkin @helen-dikareva @AndreyBelym

Note that we've dropped Node 0.10 support with this feature.

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 29ee325 have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 1c38bdb have failed. See details:

Compiler._setupSourceMapsSupport();
}

static getSupportedTestFileExtensions () {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can get extensions once, after compilers' creation

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok, do not mind



// Const
APIBasedTestFileCompilerBase.EXPORTABLE_LIB_PATH = join(__dirname, '../../api/exportable-lib');
Copy link
Collaborator

Choose a reason for hiding this comment

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

we can use static get for this

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think declare a const and use static get will be more in es6 style


static _reportErrors (diagnostics) {
// NOTE: lazy load the compiler
var ts = require('typescript');
Copy link
Collaborator

Choose a reason for hiding this comment

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

may be use get for ts

Copy link
Collaborator

Choose a reason for hiding this comment

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

forget it)

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit 1c38bdb have passed. See details:

"testcafe-reporter-json": "^2.1.0",
"testcafe-reporter-list": "^2.1.0",
"testcafe-reporter-minimal": "^2.1.0",
"testcafe-reporter-spec": "^2.1.1",
"testcafe-reporter-xunit": "^2.1.0",
"time-limit-promise": "^1.0.2",
"tree-kill": "^1.1.0",
"typescript": "^2.2.2",

Choose a reason for hiding this comment

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

Is it possible to make typescript a peer dependency? Likely many projects are already going to have typescript pulled in as a dependency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@RichiCoder1 Is there any problem with having ts as dependency? Unlike e.g. babel it has zero dependencies and package size is quite small. Moreover, if you already have ts installed package manager will more likely link already installed version.

Choose a reason for hiding this comment

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

True, but it does open yourself up to issues if Typescript releases a major version, and the typescript package is yet another package for end users. That being said, I don't feel strongly about this :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, but we'll be open for such issues anyway, i.e. programmatical API that we use could change with a major version bump.

Copy link
Contributor

@AndreyBelym AndreyBelym left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Collaborator

@helen-dikareva helen-dikareva left a comment

Choose a reason for hiding this comment

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

:)

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 96a61fc have failed. See details:

2 similar comments
@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 96a61fc have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 96a61fc have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 5ef519e have failed. See details:

@inikulin
Copy link
Contributor Author

@testcafe-build-bot \retest

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 5ef519e have failed. See details:

@AlexanderMoskovkin
Copy link
Contributor

The only functional test is failed. It relates to the pressKey automation in Safari. It failed in all current builds (pull requests and master branch), so it's not related to the current pull request, but I think it's because browser version was updated on BrowserStack. We are investigating it.
So, I think we can ignore this test and merge the pull request if there are no changes requests here.

@inikulin inikulin merged commit 6a2a951 into DevExpress:master May 12, 2017
@inikulin inikulin deleted the gh408 branch May 12, 2017 10:38
kirovboris pushed a commit to kirovboris/testcafe-phoenix that referenced this pull request Dec 18, 2019
* Introduce TestFileCompilerBase

* Refactor compiler dir structure

* Extract APIBasedTestFileCompilerBase

* Update legacy api

* Compiler basics

* Exportable lib resolution

* Basic test

* Mixed deps test

* Definitions

* More definitions

* More definitions

* More definitions

* More definitions

* More definitions

* More definitions

* Test Selector definitions

* More definition tests.

* Compilation tests

* Functional smoke tests

* CLI support

* Descriptions

* Description

* Drop node 10 support

* Fix Helen's remarks.
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.

6 participants