How can I run tests from test-utils.ts for a new sync target?

Hello everyone.
I'm a kinda smart developer but from an absolutely different domain. And I never code TypeScript before.

Right now I'm adding new YandexDisk sync target for Joplin. And I'm facing some issues related to test. I have no idea how to properly test my new sync target.

I'm looking now at packages/lib/testing/test-utils.ts
Looks like this code could test different file storage providers.
But only one provider is hard-coded to be ON setSyncTargetName('memory');

The question is how to run this code for a custom cloud provider like a OneDrive ?

  • what is the cli command to execute only this test ?
  • in what directory I should put credentials file like onedrive-auth.txt ?
1 Like

"memory" is the sync target we use by default for test units because it's faster, but as you can see there are other supported sync targets there, but currently commented out:

// setSyncTargetName('filesystem');
// setSyncTargetName('nextcloud');
// setSyncTargetName('dropbox');
// setSyncTargetName('onedrive');
// setSyncTargetName('amazon_s3');
// setSyncTargetName('joplinServer');

So to test you'd replace the memory one with eg setSyncTargetName('yandex')

Then under initFileApi() still in test-utils.ts you can add sync target specific initialisation code. The files like onedrive-auth.txt go in ~/joplin-credentials. You can create one for Yandex if needed and access it with, for example, await credentialFile('yandex-auth.txt')

I still have one last stupid question.

What CLI command would run tests only from test-utils.ts ?

test-utils as the name says are just utils used by other tests. If you only want to run sync related tests I think running yarn test synchronize would do that. Try also yarn test to be sure all tests are included because some make use of the active sync target even though they don't have "synchronize" in the name.