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

Use typescript for global hooks #6867

Closed
Georgegriff opened this issue Feb 11, 2022 · 4 comments
Closed

Use typescript for global hooks #6867

Georgegriff opened this issue Feb 11, 2022 · 4 comments
Labels
FREQUENCY: level 1 STATE: Stale An outdated issue that will be automatically closed by the Stale bot. TYPE: enhancement The accepted proposal for future implementation.

Comments

@Georgegriff
Copy link

What is your Scenario?

We have hook code written in typescript that we currently have to copy and paste to all our tests, it would be nice to be able to define our global fixture/test hook code once but because it's written in typescript we would have to pre-compile it in order to use it in the JavaScript config file

What are you suggesting?

Some mechanism for defining a file where you hooks can live instead of the code being directly in the config file. For example if you could specify a path to your hooks file instead of the functions directly this code could be written in typescript and compiled by testcafe

What alternatives have you considered?

Compiling the code before using it, this would be a little awkward as it would require two typescript builds one before testcafe starts and the one by testcafe.

I had the thought that we could maybe do this as a work around:

module.exports = {
    hooks: {
        fixture: {
            before: async (ctx) => {
                const {before} = require("./ts-compiled/hooks")
                await before(ctx);
            },
            after: async (ctx) => {
                const {after} = require("./ts-compiled/hooks")
                await after(ctx);
            }
        },
        test: {
            before: async (t) => {
                const {beforeTest} = require("./ts-compiled/hooks")
                await beforeTest(ctx);
            },
            after: async (t) => {
                const {afterTest} = require("./ts-compiled/hooks")
                await afterTest(ctx);
            }
        }
    }
};

but there does not seem to be a way to find out where the TS is compiled to by testcafe or not clear if testcafe would know to compile these files at all

Additional context

No response

@Georgegriff Georgegriff added the TYPE: enhancement The accepted proposal for future implementation. label Feb 11, 2022
@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Feb 11, 2022
@AlexKamaev
Copy link
Contributor

Thank you for your suggestion. We'll take it into account.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Feb 14, 2022
@srsholmes
Copy link

This would be really handy to have.

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Apr 21, 2022
@AlexSkorkin AlexSkorkin removed the STATE: Need response An issue that requires a response or attention from the team. label Apr 21, 2022
@github-actions
Copy link

This issue has been automatically marked as stale because it has not had any activity for a long period. It will be closed and archived if no further activity occurs. However, we may return to this issue in the future. If it still affects you or you have any additional information regarding it, please leave a comment and we will keep it open.

@github-actions github-actions bot added the STATE: Stale An outdated issue that will be automatically closed by the Stale bot. label Apr 22, 2023
@github-actions
Copy link

github-actions bot commented May 3, 2023

We're closing this issue after a prolonged period of inactivity. If it still affects you, please add a comment to this issue with up-to-date information. Thank you.

@github-actions github-actions bot closed this as completed May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FREQUENCY: level 1 STATE: Stale An outdated issue that will be automatically closed by the Stale bot. TYPE: enhancement The accepted proposal for future implementation.
Projects
None yet
Development

No branches or pull requests

4 participants