Question

Use absolute paths in imports in CLI implementation using TS.

  • 7 September 2022
  • 3 replies
  • 36 views

When we import some modules to certain function or component, How to use absolute path for the imports ?(This implementation is related to some actions and triggers that we are implemented using type script and used jest framework for unit testing. )

I already tried some solutions on internet with some configuration changes, but still didn’t found a solution.

https://medium.com/@fmoessle/typescript-paths-with-ts-node-ts-node-dev-and-jest-671deacf6428

https://stackoverflow.com/questions/57848805/typescript-relative-imports-are-turned-into-absolute-imports-when-building-w

assume we imoprt a module named logincomponent from ,

import { logincomponent } from 'api';

and when we run the zapier test, it mention that module not found named logincomponent.

 

need to know how the configuration need to be changed in zapier cli using type script for use absolute paths imports into my implementation.


3 replies

Userlevel 3
Badge +4

Hey there,

Looking through your apps, I'm not able to find an api file with a logincomponent in it.

For most of our tests we use a format like

const response = require('dotdot/fixtures/responses/200.json');  // I had to replace actual dots with the phrase “dot” in order to post this

Would that format work for you? If not we'd probably need more information about the structure of your code, where each file is, etc.

You might find we're able to discuss the specifics of your code via email if you reach out while logged in to your developer account at https://developer.zapier.com/contact

Hope that helps! Let us know if you still have questions.

Hey there,

Looking through your apps, I'm not able to find an api file with a logincomponent in it.

For most of our tests we use a format like

const response = require('dotdot/fixtures/responses/200.json');  // I had to replace actual dots with the phrase “dot” in order to post this

Would that format work for you? If not we'd probably need more information about the structure of your code, where each file is, etc.

You might find we're able to discuss the specifics of your code via email if you reach out while logged in to your developer account at https://developer.zapier.com/contact

Hope that helps! Let us know if you still have questions.

Yes this (‘dotdot/’) format works for me. But I needed to define those paths in absolute path. But seems it isn`t possible with Zapier bundleing process. 

Userlevel 3
Badge +4

Hey PASINDU,

Interesting. I don’t know off hand if what you’re trying to do will work, so I was trying to dig in myself and try to figure out exactly what was going on.

Since I couldn’t find any logincomponent in your code, I couldn’t test it out. Does it actually exist somewhere? Can you import it using the relative path syntax? If so, what is the exact line you use to import it?

And I’m curious, why do you need to do an absolute import?

Thanks! 

Reply