Skip to content

Add support for 'clientScripts' (close #1739)#3880

Merged
miherlosev merged 18 commits intoDevExpress:masterfrom
benmonro:feature/additional-scripts
Jul 24, 2019
Merged

Add support for 'clientScripts' (close #1739)#3880
miherlosev merged 18 commits intoDevExpress:masterfrom
benmonro:feature/additional-scripts

Conversation

@benmonro
Copy link
Copy Markdown
Contributor

@benmonro benmonro commented Jun 10, 2019

This PR will add a new section to the config file: "clientScripts"

example:

 {
    "src": "test.js",
    "browsers": [
        "chrome",
    ],
    "clientScripts": [
        "./node_modules/@testing-library/dom/dist/@testing-library/dom.umd.js"
    ]
}

adding this to your config will cause testcafe to inject the above scripts into the browser as a script tag.

This will be very useful for testcafe-testing-library which needs to inject DomTestingLibrary into the dom, on each page-load, and will thus now only need to be configured once, and will then work on each page.

resolves #1739

@testcafe-build-bot
Copy link
Copy Markdown
Collaborator

@testcafe-build-bot
Copy link
Copy Markdown
Collaborator

@testcafe-build-bot
Copy link
Copy Markdown
Collaborator

@miherlosev
Copy link
Copy Markdown
Collaborator

Hi @benmonro
 
Thank you for your interest in TestCafe.
After discussing it with the team, I wrote the final API for this feature: #1739 (comment). The feature requires writing a large amount of code. It's not easy. However, you can implement this feature step by step.
As the first step, I suggest you implement the described above API only for the configuration file.

@benmonro
Copy link
Copy Markdown
Contributor Author

benmonro commented Jun 13, 2019

sounds good, I actually like that proposed api better @miherlosev

Just started a new job at Walmart Labs, so not sure how much time i'll be able to spend on it, so feel free to take this PR and modify it to fit that API or do whatever you like with it. You know I ❤️ you guys! keep up the great work, i sing your praise every day!

-Ben

@benmonro benmonro changed the title [Work in progress] add support for 'additionalScripts' in configuration. add support for 'clientScripts' in configuration. Jun 17, 2019
@testcafe-build-bot
Copy link
Copy Markdown
Collaborator

@testcafe-build-bot
Copy link
Copy Markdown
Collaborator

@testcafe-build-bot
Copy link
Copy Markdown
Collaborator

@testcafe-build-bot
Copy link
Copy Markdown
Collaborator

@testcafe-build-bot
Copy link
Copy Markdown
Collaborator

@testcafe-build-bot
Copy link
Copy Markdown
Collaborator

@miherlosev miherlosev force-pushed the feature/additional-scripts branch from 5cd7d19 to 37d3fc1 Compare June 27, 2019 08:57
@testcafe-build-bot
Copy link
Copy Markdown
Collaborator

@testcafe-build-bot
Copy link
Copy Markdown
Collaborator

@miherlosev miherlosev changed the title add support for 'clientScripts' in configuration. [WIP] Add support for 'clientScripts' Jun 28, 2019
@miherlosev miherlosev force-pushed the feature/additional-scripts branch from d9a799c to 35ba768 Compare June 28, 2019 08:01
@testcafe-build-bot
Copy link
Copy Markdown
Collaborator

@testcafe-build-bot
Copy link
Copy Markdown
Collaborator

@testcafe-build-bot
Copy link
Copy Markdown
Collaborator

@AndreyBelym AndreyBelym added this to the Sprint #36 milestone Jul 1, 2019
@testcafe-build-bot
Copy link
Copy Markdown
Collaborator

@testcafe-build-bot
Copy link
Copy Markdown
Collaborator

@testcafe-build-bot
Copy link
Copy Markdown
Collaborator

@testcafe-build-bot
Copy link
Copy Markdown
Collaborator

@testcafe-build-bot
Copy link
Copy Markdown
Collaborator

@testcafe-build-bot
Copy link
Copy Markdown
Collaborator

@miherlosev miherlosev force-pushed the feature/additional-scripts branch from a3f41f8 to 9fe10d6 Compare July 3, 2019 09:58
@testcafe-build-bot
Copy link
Copy Markdown
Collaborator

@testcafe-build-bot
Copy link
Copy Markdown
Collaborator

@miherlosev
Copy link
Copy Markdown
Collaborator

@testcafe-build-bot retest

@testcafe-build-bot
Copy link
Copy Markdown
Collaborator

@testcafe-build-bot
Copy link
Copy Markdown
Collaborator

@testcafe-build-bot
Copy link
Copy Markdown
Collaborator

@miherlosev
Copy link
Copy Markdown
Collaborator

@testcafe-build-bot retest

@testcafe-build-bot
Copy link
Copy Markdown
Collaborator

@miherlosev miherlosev force-pushed the feature/additional-scripts branch from 05fe0ab to 3226191 Compare July 24, 2019 10:57
@testcafe-build-bot
Copy link
Copy Markdown
Collaborator

@miherlosev miherlosev merged commit 8c6e721 into DevExpress:master Jul 24, 2019
kirovboris pushed a commit to kirovboris/testcafe-phoenix that referenced this pull request Dec 18, 2019
)

* initial

* fix wrong rebase

* new logic for resolving relative paths (test api and others)

* refactoring

* fix tests

* provide error messages for uncaught errors occured in injected client scripts

* fix tests

* fix error messages

* fix server tests

* fix relative paths

* fix type definition

* prevent multiple method calls for clientScripts and requestHooks

* fix an error message during module loading

* specify execution order for clientScripts and requestHooks

* skip test

* skip test

* refix the test

* fix client scripts loading order and handle module path resolving errors
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.

Add the capability to execute a custom script before page initialization scripts

7 participants