Solvedtestcafe Custom Test Metadata/Tags for use in Reporters

Are you requesting a feature or reporting a bug?

Feature Request

What is the current behavior?

TestCafe does not support pipelining custom metadata/tags to a reporter. However, I do see in the previous incarnation there was a form of this: https://testcafe.devexpress.com/Documentation/API_Reference/Test_Fixture_API/Common_Concepts/#Test_Run_Metadata

What is the expected behavior?

Ideally we would like to be able to define metadata/taga in our tests and have it available to the reporters.

Use Cases:

  • Severity
  • Test Management Tool ID / URL

Example:

test('My first test', {severity: critical, testID: TC-0013}, async t => {
    // Test code
});

or

test('My first test', async t => {
    t.meta('severity', 'critical')
    t.meta('testID', 'TC-0013')
});

such that the testRunInfo object in reportTestDone would have access

reportTestDone (name, testRunInfo) {
    if (testRunInfo.severity)
        title += ' (testRunInfo.severity)';

    if (testRunInfo.testID)
        title += ` (testRunInfo.testID)`;
}

If you are familiar with RSpec, you will know this concept well. Here is what it looks like: https://relishapp.com/rspec/rspec-core/docs/metadata/user-defined-metadata

However, in RSpec it is much more powerful as tags/metadata can be used to drive whether tests should be run/skipped - and also drive logic within the tests themselves.

26 Answers

βœ”οΈAccepted Answer

Yep, TestCafe doesn't support it right now. TestCafe uses its own compiler under the hood.

TestCafe doesn't provide an ability to add some custom info from the test to its report. But we have test context and fixture context objects. We can implement sharing info between tests and reports by using them. It may look in the following way:

// test.js 
test('Test1', async t => {
     t.fixtureCtx.severity = 'critical';
     t.ctx.testID = 'TC-0013';
});

// custom-report.js
reportTestDone (name, testRunInfo) {
    const severity = testRunInfo.fixtureCtx.severity;
    const testID   = testRunInfo.ctx.testID;

    ...
}

How do you like this way? /CC @tk8817 @DevExpress/testcafe-docs @VasilyStrelyaev

Wondering if I can put together a PR to add support

When we will up with the final API the PR is welcome. We will provide any assistance.

Related Issues:

32
testcafe Add the capability to disable page reloading between tests
I think this would be hugely beneficial for single page applications Based on the #1509 question It'...
16
testcafe declare var test on global scope issue
having the same issue with jest and #testcafe -> both expose test as global type ...
5
testcafe Custom Test Metadata/Tags for use in Reporters
Yep TestCafe doesn't support it right now TestCafe uses its own compiler under the hood ...
3
testcafe Mouse down, mouse up behaviour
Is there a workaround available? I need to migrate the following from puppeteer to testcafe. ...
469
next.js Module not found: Can't resolve 'fs'
Update for modern Next.js (9.4+) You can safely use fs within getStaticProps or getServerSideProps n...
230
mocha timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.
just add in your package.json under scripts Then you can just run I'm getting the following error wh...
149
next.js Adding GA script tag?
No need for react-ga Use the google tag manager with the <Head> component to inject analytics ...
122
mocha Error: Resolution method is overspecified.
async functions (babel) with done also break. This: will result in an error Error: Resolution method...
100
next.js getServerSideProps cannot be serialized as JSON. Please only return JSON serializable data types
@timneutkens I don't get why this issue is closed It seems quite a lot of people are still stumbling...
98
mocha mocha 4 doesn't exit unlike mocha 3
Other than providing a quick fix (use --exit) I do agree they left the core issue of finding the fau...
92
debug npm WARN enoent ENOENT: no such file or directory, open '<root>/node_modules/supertest/package.json'
No That's not an issue of debug package I think it's related to NPM v3's changed installation behavi...
90
next.js Could not freeze filename
It has happened to me deleting the cache solved it rm -rf node_modules/.cache Recently I've updated ...
90
next.js Ability to co-locate non-page files in the pages directory
@probablyup this is so easy set pageExtensions as below a file tree like below and only /list page a...
86
next.js Nextjs causing hard refresh when i click in the Link
Have you tried this format for your Link? Here is a good example of this type of routing for dynamic...
84
next.js Link as styled component
Hey guys At version 3.0.1-beta.13+ I followed #799 but couldn't get a clean way to have a styled-com...
84
next.js Cannot import Typescript files from outside of 'dir' directory
If anyone needs this right now it is available as an experimental feature in 10.1.2 An example next....
83
next.js Image optimisation external resource not working
@raphaelbs I had a similar issue in that it worked locally but not in prod Bug report Describe the b...
83
next.js 8.0.0 - dynamic import causing 'You may need an appropriate loader...' error
Ok here is the winning combo (made sure is 100% reproducible): My project already had next v7 npm in...
79
next.js Cannot read property 'prefetch' and 'push' of null
I was able to work around the issue by mocking next/link instead of next/router: ...
77
mocha Async test fails with timeout instead of assertion error
I ran into a similar problem and eventually realized you shouldn't use done when testing asynchronou...
75
next.js Include css in a next project?
Create a /static folder at the same level the /pages folder I know that Next uses Glamor and css-in-...
75
next.js Handling images
@impronunciable I think its not so good idea to store all the images in the same global static folde...
74
next.js Generated static files html files have wrong assets paths
Thanks @cargallo πŸ‘ Was trying to serve static exported files through an Electron app and was wonder...
69
next.js Next.js API routes (and pages) should support reading files
Workaround I'm using: and in the location you need the path I know this doesn't solve the need to re...
64
next.js Error after upgrading from 9.3.6 to 9.4
@aralroca Have you tried deleting the .next directory and running npm run dev again? ...
64
next.js Dev mode on Next.js v12 breaks with combination of features
This seems to be a particular case with Chakra UI and some other deps As a temporary workaround you ...
60
next.js How to mock useRouter?
I ended up mocking it like this I only need the useRouter export so this worked well enough for my p...
58
next.js [Next 9.0] How to remove the clickable label "Prerendered Page" and loading Icon ?
https://nextjs.org/docs/#automatic-prerender-indicator I want to remove Prerendered Page label and i...
58
next.js Add a Dynamic Sitemap example that works with the new Dynamic Routes
I am making use of the new rewrites feature of NextJS v9.1.4 Inside of pages/api/sitemap.ts I run th...
57
next.js Getting ReactDOMServer does not yet support Suspense error while using styled-components
In my case following error Error: ReactDOMServer does not yet support Suspense What version of Next....
55
next.js False positive report of "API resolved without sending a response"
@gaku-sei it is most likely caused by the callback as we can't detect you are still doing work in th...
54
next.js Provide example using Context API with custom _app.js
I have an example if anyone wants to clean it up and turn it into a PR: NoteProvider.js _app.js Then...
53
next.js css-loader + CSS modules pure selectors
I solved my issues by moving away from implicit HTML calls (ex: nav and <nav> ) for specific element...
53
next.js Feature request: Basepath support
Any update on this.. last year around this time i ran into this issue Now a year later ...
52
next.js SVGR fails to load SVGs with Next 11
The fix is available in next@11.0.1-canary.4 You can try it out today with yarn add next@canary Than...
52
next.js Route matching with params
@dstreet Personally I think package.json should only contain NPM configuration (i.e dependencies scr...
49
next.js Non-standardized PostCSS config file doesn't support require statements
the workaround Bug report Describe the bug With the introduction of the marvelous Built-in CSS Suppo...
48
mocha Cannot find module 'tap', but tap isn't listed as a dependency
It's something I run into as well I think that 's because you run a test from your node_modules ...
47
next.js Support ES module format (ESM) in next.config.js
I've opened a PR that changes from require() to import() for config loading and adds support for nex...
46
next.js Feasibility of micro frontends
@janus-reith Thank you I've been really frustrated that nobody actually solved this ...
46
next.js next dev rewrites tsconfig.json
isolatedModules is certainly debatable – for example we'd like to make a tradeoff between performanc...
45
next.js next/image memory leak?
Hi I'm the sharp maintainer and I've just been made aware that Next.js switched away from using it d...
44
next.js Unable to import module 'now__launcher'
Because this is the first result in google and there is no link to the other issue ...
43
next.js A first-class way to internationalize a statically exported Next.js app
Alright! Here's a summary of what I did for future adventurers: First in your next config ...
42
next.js [RFC] CSS Support
Whatever we do here can we make sure it's still easy to use custom PostCSS plugins like it is now wi...
41
next.js with-redux-persist SSR issue
@jeffersoncustodio820 Your solution is good but this causes ReactDOM.hydrate to throw an HTML mismat...
40
next.js Custom loaders are not recognized by next export
Potentially related https://github.com/vercel/next.js/discussions/19372 FWIW What version of Next.js...
39
next.js Error: Cannot find module 'webpack'
This happens because Next.js 10.0.6 introduces support for dual-loading webpack as part of our work ...
39
next.js Elegance of dynamic imports in TypeScript
I also had same problem and solved it in a way of which makes use of generics First you should defin...
37
next.js Truly static pages without react app
I also did something similar to @danielr18 The problem with his example is that JavaScript files are...