diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index 5a243fae45..a7d586b025 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -78,17 +78,21 @@ module.exports = class TestTab extends ViewPlugin { return { assertLibCode, accountsLibCode: this.testRunner.accountsLibCode } } + async createTestLibs () { + const provider = await this.fileManager.currentFileProvider() + if (provider) { + provider.addExternal('.deps/remix-tests/remix_tests.sol', assertLibCode, 'remix_tests.sol') + provider.addExternal('.deps/remix-tests/remix_accounts.sol', this.testRunner.accountsLibCode, 'remix_accounts.sol') + } + } + async onActivation () { const isSolidityActive = await this.call('manager', 'isActive', 'solidity') if (!isSolidityActive) { await this.call('manager', 'activatePlugin', 'solidity') } await this.testRunner.init() - const provider = await this.fileManager.currentFileProvider() - if (provider) { - provider.addExternal('.deps/remix-tests/remix_tests.sol', assertLibCode, 'remix_tests.sol') - provider.addExternal('.deps/remix-tests/remix_accounts.sol', this.testRunner.accountsLibCode, 'remix_accounts.sol') - } + await this.createTestLibs() this.updateRunAction() } @@ -120,6 +124,10 @@ module.exports = class TestTab extends ViewPlugin { this.setCurrentPath(this.defaultPath) }) + this.on('filePanel', 'workspaceCreated', async () => { + this.createTestLibs() + }) + this.testRunner.event.on('compilationFinished', (success, data, source) => { if (success) { this.allFilesInvolved.push(...Object.keys(data.sources)) diff --git a/libs/remix-core-plugin/src/lib/compiler-content-imports.ts b/libs/remix-core-plugin/src/lib/compiler-content-imports.ts index 670ce0fda7..121e05f864 100644 --- a/libs/remix-core-plugin/src/lib/compiler-content-imports.ts +++ b/libs/remix-core-plugin/src/lib/compiler-content-imports.ts @@ -118,14 +118,6 @@ export class CompilerImports extends Plugin { * @returns {Promise} - string content */ async resolveAndSave (url, targetPath, testRunner = null) { - if (url.indexOf('remix_tests.sol') !== -1 || url.indexOf('remix_accounts.sol') !== -1) { - let content - if (url === 'remix_tests.sol') content = assertLibCode - else if (url === 'remix_accounts.sol' && testRunner) content = testRunner.accountsLibCode - const provider = await this.call('fileManager', 'getProviderOf', null) - if (provider) provider.addExternal('.deps/remix-tests/' + url, content, url) - return content - } try { const provider = await this.call('fileManager', 'getProviderOf', url) if (provider) {