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

CANNOT use API proposal: fileSearchProvider #130

Closed
pderaaij opened this issue Jul 11, 2024 · 2 comments · Fixed by #146
Closed

CANNOT use API proposal: fileSearchProvider #130

pderaaij opened this issue Jul 11, 2024 · 2 comments · Fixed by #146

Comments

@pderaaij
Copy link

Hi,

Probably this is not an issue, but a lack of understanding from my side. However, I am unable to get it working. My goal is to add e2e tests to the web version of https://github.com/foambubble/foam/.

I've replicated the setup of the sample project, but I am getting the following error:

Activating extension 'vscode.vscode-test-web-fs' failed: Extension 'vscode.vscode-test-web-fs' CANNOT use API proposal: fileSearchProvider.
Its package.json#enabledApiProposals-property declares: but NOT fileSearchProvider.
The missing proposal MUST be added and you must start in extension development mode or use the following command line switch: --enable-proposed-api vscode.vscode-test-web-fs.

My test runner is:

import * as path from 'path';
import { runTests } from '@vscode/test-web';

async function main() {
  try {
    // The folder containing the Extension Manifest package.json
    const extensionDevelopmentPath = path.resolve(__dirname, '..');

    // The path to module with the test runner and tests
    const extensionTestsPath = path.resolve(__dirname, './web/index');

    const folderPath = path.resolve(__dirname, './../../.test-workspace');

    const attachArgName = '--waitForDebugger=';
    const waitForDebugger = process.argv.find(arg =>
      arg.startsWith(attachArgName)
    );

    // Start a web server that serves VSCode in a browser, run the tests
    await runTests({
      browserType: 'chromium',
      extensionDevelopmentPath,
      extensionTestsPath,
      folderPath,
      verbose: true,
      waitForDebugger: waitForDebugger
        ? Number(waitForDebugger.slice(attachArgName.length))
        : undefined,
    });
  } catch (err) {
    console.error('Failed to run tests');
    process.exit(1);
  }
}

main();

My suite looks like:

/*global mocha:readonly*/
/*global __WebpackModuleApi:readonly*/

// Imports mocha for the browser, defining the `mocha` global.
require('mocha/mocha');

export function run(): Promise<void> {
  console.log('Enter run');
  return new Promise((c, e) => {
    mocha.setup({
      ui: 'tdd',
      reporter: undefined,
    });

    // Bundles all files in the current directory matching `*.test`
    const importAll = (r: __WebpackModuleApi.RequireContext) =>
      r.keys().forEach(r);
    importAll(require.context('.', true, /\.webtest$/));

    try {
      console.log('Running test////');
      // Run the mocha test
      mocha.run(failures => {
        console.log(failures);
        if (failures > 0) {
          e(new Error(`${failures} tests failed.`));
        } else {
          c();
        }
      });
    } catch (err) {
      console.error(err);
      e(err);
    }
  });
}

And I am using webpack and tsc config similar to the sample project. Eventually, I run the test suite with the following run script:

"pretest:web": "yarn compile-web && tsc -p tsconfig.webTest.json",
"test:web": "node ./out/web/test/run-tests-for-web-extension.js",

I am lost how to solve this. Any suggestions are welcome.

@wkillerud
Copy link
Contributor

Hello.

I'm not able to reproduce this problem with the information you've provided. Can you please make a minimal reproduction in a GitHub repo?

There's test coverage for the file search provider and the tests run OK on main. I'm also running tests that depend on this feature over in this repo.

@pderaaij
Copy link
Author

Thanks for thinking along! Based on your repository, I've kept fiddling around. I've got it working and learned two things.

  1. I had some issues in my test runner, pointing to the incorrect directories. In my case, I pointed to the src folder and not the folder containing package.json.
  2. For the open-in-browser command, I got it working by not starting the browsers pointing to a workspace. So boot up blank and open the same folder manually. This won't cause the activation problem to occur. Not sure what the cause is.

I am good for now, but not sure if this should be the correct behaviour. Could it be caused by the monorepo structure of foam?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants