Search code examples
javascriptautomated-testse2e-testingweb-testingtestcafe

Page model imports


I'm writing tests using TestCafe and, as my page models grow, my imports are consuming a lot of space. So it would be good to have the imports in a concise way.

Page Model 1:

export ClassA {...}

export ClassB {...}

Page Model 2:

export Class C {...}

export Class D {...}

Then on my test file, I'm using

import { ClassA, ClassB, ClassC, ClassD } from './pages' 

It's clear that when the number of classes gets larger, my import will become large.

Is it possible to use a wildcard * in this case? What's the recommended way?

import * from 'page_model1'
import * from 'page_model2'
...

or

import * from './pages'

Solution

  • I believe that they will be accesible using the following piece of code

    import * as Pages from './pages';
    
    // Then used it as this
    Pages.ClassA;