Best JavaScript code snippet using root
ArtifactsManager.test.js
Source:ArtifactsManager.test.js
...339 });340 });341 describe('onCreateExternalArtifact', () => {342 it('should call onCreateExternalArtifact in a specific plugin', async () => {343 await artifactsManager.onCreateExternalArtifact({344 pluginId: 'testPlugin',345 artifactPath: '/tmp/path/to/artifact',346 artifactName: 'Example',347 });348 expect(testPlugin.onCreateExternalArtifact).toHaveBeenCalledWith({349 artifact: expect.any(Object),350 name: 'Example',351 });352 });353 });354 describe('onBeforeLaunchApp', () => {355 it('should call onBeforeLaunchApp in plugins', async () => {356 const launchInfo = {357 deviceId: 'testDeviceId',...
TwoSnapshotsPerTestPlugin.test.js
Source:TwoSnapshotsPerTestPlugin.test.js
...60 });61 });62 describe('onCreateExternalArtifact', () => {63 it('should throw error if { artifact } is not defined', async () => {64 await expect(plugin.onCreateExternalArtifact({ name: 'Hello'})).rejects.toThrowError();65 });66 it('should set snapshot in key-value map and track it', async () => {67 const artifact = new ArtifactMock('test');68 await plugin.onCreateExternalArtifact({ name: 'hello', artifact });69 expect(plugin.snapshots.fromSession['hello']).toBe(artifact);70 expect(api.trackArtifact).toHaveBeenCalledWith(artifact);71 });72 });73 describe('when the plugin should keep a test artifact', () => {74 beforeEach(() => plugin.configureToKeepArtifacts(true));75 describe('when onTestStart and onTestDone are called', () => {76 beforeEach(async () => {77 await plugin.onTestStart(testSummaries.running());78 await plugin.onTestDone(testSummaries.passed());79 });80 it('should create the second test artifact', () => {81 expect(plugin.createTestArtifact).toHaveBeenCalledTimes(2);82 });83 it('should start and stop the second test artifact', () => {84 expect(plugin.snapshots.fromTest['testDone'].start).toHaveBeenCalledTimes(1);85 expect(plugin.snapshots.fromTest['testDone'].stop).toHaveBeenCalledTimes(1);86 });87 it('should put the second test artifact under tracking', () => {88 expect(api.trackArtifact).toHaveBeenCalledWith(plugin.snapshots.fromTest['testDone']);89 });90 it('should schedule two saving operations and specify itself as an initiator', () => {91 expect(api.requestIdleCallback).toHaveBeenCalledTimes(2);92 expect(api.requestIdleCallback.mock.calls[0]).toEqual([expect.any(Function)]);93 expect(api.requestIdleCallback.mock.calls[1]).toEqual([expect.any(Function)]);94 });95 it('should schedule to save and untrack the first artifact', async () => {96 const [saveRequest] = api.requestIdleCallback.mock.calls[0];97 expect(plugin.snapshots.fromTest['testStart'].save).not.toHaveBeenCalled();98 expect(api.untrackArtifact).not.toHaveBeenCalled();99 await saveRequest();100 expect(plugin.snapshots.fromTest['testStart'].save).toBeCalledWith('test/testStart.png');101 expect(api.untrackArtifact).toBeCalledWith(plugin.snapshots.fromTest['testStart']);102 });103 it('should ultimately save and untrack the second artifact', async () => {104 const [saveRequest] = api.requestIdleCallback.mock.calls[1];105 expect(plugin.snapshots.fromTest['testDone'].save).not.toHaveBeenCalled();106 expect(api.untrackArtifact).not.toHaveBeenCalled();107 await saveRequest();108 expect(plugin.snapshots.fromTest['testDone'].save).toBeCalledWith('test/testDone.png');109 expect(api.untrackArtifact).toBeCalledWith(plugin.snapshots.fromTest['testDone']);110 });111 });112 describe('when an external snapshot is created in the midst of a test', function() {113 let artifact;114 beforeEach(async () => {115 artifact = new ArtifactMock('screenshot');116 await plugin.onTestStart(testSummaries.running());117 await plugin.onCreateExternalArtifact({118 artifact,119 name: 'final_name',120 });121 await plugin.onTestDone(testSummaries.passed());122 });123 it('should be saved using the suggested name and untracked', async () => {124 expect(artifact.save).not.toBeCalledWith('test/final_name.png');125 expect(api.untrackArtifact).not.toHaveBeenCalled();126 await Promise.all(api.requestIdleCallback.mock.calls.map(s => s[0]()));127 expect(artifact.save).toBeCalledWith('test/final_name.png');128 expect(api.untrackArtifact).toHaveBeenCalled();129 });130 });131 describe('when an external snapshot is created before beforeEach', function() {132 let artifact;133 beforeEach(async () => {134 artifact = new ArtifactMock('screenshot');135 await plugin.onCreateExternalArtifact({136 artifact,137 name: 'final_name',138 });139 await plugin.onTestStart(testSummaries.running());140 });141 it('should be saved using the suggested name and untracked', async () => {142 expect(artifact.save).not.toBeCalledWith('final_name.png');143 expect(api.untrackArtifact).not.toHaveBeenCalled();144 await Promise.all(api.requestIdleCallback.mock.calls.map(s => s[0]()));145 expect(artifact.save).toBeCalledWith('final_name.png');146 expect(api.untrackArtifact).toHaveBeenCalled();147 });148 });149 describe('when an external snapshot is created before Detox cleanup', function() {150 let artifact;151 beforeEach(async () => {152 artifact = new ArtifactMock('screenshot');153 await plugin.onTestStart(testSummaries.running());154 await plugin.onTestDone(testSummaries.passed());155 await plugin.onCreateExternalArtifact({156 artifact,157 name: 'final_name',158 });159 await plugin.onBeforeCleanup();160 });161 it('should be saved using the suggested name and untracked', async () => {162 expect(artifact.save).not.toBeCalledWith('final_name.png');163 expect(api.untrackArtifact).not.toHaveBeenCalled();164 await Promise.all(api.requestIdleCallback.mock.calls.map(s => s[0]()));165 expect(artifact.save).toBeCalledWith('final_name.png');166 expect(api.untrackArtifact).toHaveBeenCalled();167 });168 });169 });170 describe('when the plugin should not keep a test artifact', () => {171 beforeEach(() => plugin.configureToKeepArtifacts(false));172 describe('when onTestStart and onTestDone are called', () => {173 beforeEach(async () => {174 await plugin.onTestStart(testSummaries.running());175 await plugin.onTestDone(testSummaries.passed());176 });177 it('should not create the second test artifact', () => {178 expect(plugin.createTestArtifact).toHaveBeenCalledTimes(1);179 });180 it('should schedule a discard operation for the first artifact and specify itself as an initiator', () => {181 expect(api.requestIdleCallback).toHaveBeenCalledTimes(1);182 expect(api.requestIdleCallback.mock.calls[0]).toEqual([expect.any(Function)]);183 });184 it('should ultimately discard and untrack the first artifact', async () => {185 const [discardRequest] = api.requestIdleCallback.mock.calls[0];186 expect(plugin.snapshots.fromTest['testStart'].discard).not.toHaveBeenCalled();187 expect(api.untrackArtifact).not.toHaveBeenCalled();188 await discardRequest();189 expect(plugin.snapshots.fromTest['testStart'].discard).toHaveBeenCalledTimes(1);190 expect(api.untrackArtifact).toBeCalledWith(plugin.snapshots.fromTest['testStart']);191 });192 });193 describe('when an external snapshot is created in the midst of a test', function() {194 let artifact;195 beforeEach(async () => {196 artifact = new ArtifactMock('screenshot');197 await plugin.onTestStart(testSummaries.running());198 await plugin.onCreateExternalArtifact({199 artifact,200 name: 'final_name',201 });202 await plugin.onTestDone(testSummaries.passed());203 });204 it('should be discarded and untracked', async () => {205 expect(artifact.discard).not.toHaveBeenCalled();206 expect(api.untrackArtifact).not.toHaveBeenCalled();207 await Promise.all(api.requestIdleCallback.mock.calls.map(s => s[0]()));208 expect(artifact.discard).toHaveBeenCalled();209 expect(api.untrackArtifact).toHaveBeenCalledWith(artifact);210 });211 });212 });...
ArtifactsManager.js
Source:ArtifactsManager.js
...87 }88 async onLaunchApp(appLaunchInfo) {89 await this._callPlugins('plain', 'onLaunchApp', appLaunchInfo);90 }91 async onCreateExternalArtifact({ pluginId, artifactName, artifactPath }) {92 await this._callSinglePlugin(pluginId, 'onCreateExternalArtifact', {93 artifact: new FileArtifact({ temporaryPath: artifactPath }),94 name: artifactName,95 });96 }97 async onTestStart(testSummary) {98 await this._callPlugins('ascending', 'onTestStart', testSummary);99 }100 async onTestDone(testSummary) {101 await this._callPlugins('descending', 'onTestDone', testSummary);102 }103 async onSuiteStart(suite) {104 await this._callPlugins('descending', 'onSuiteStart', suite);105 }...
Using AI Code Generation
1var rootComponent = kony.sdk.mvvm.KonyApplicationContext.getAppInstance().getFormController("frmExternalArtifact").getFormModel().getViewAttributeByProperty("flxExternalArtifact", "rootComponent");2var externalArtifact = rootComponent.onCreateExternalArtifact("externalArtifact", "flxExternalArtifact", "externalArtifact");3rootComponent.addExternalArtifact("externalArtifact", externalArtifact);4var externalArtifact = this.getFormModel().getViewAttributeByProperty("externalArtifact", "externalArtifact");5var externalArtifact = this.externalArtifact;6var externalArtifact = this.getFormModel().getViewAttributeByProperty("externalArtifact", "externalArtifact");7var externalArtifact = this.getFormModel().getViewAttributeByProperty("externalArtifact", "externalArtifact");8var externalArtifact = this.getFormModel().getViewAttributeByProperty("externalArtifact", "external
Using AI Code Generation
1var rootArtifact = this;2var artifact = rootArtifact.onCreateExternalArtifact("test");3artifact.setProperty("name", "test");4artifact.setProperty("description", "test");5artifact.setProperty("version", "1.0.0");6artifact.setProperty("path", "test");7artifact.setProperty("mimeType", "text/plain");8artifact.setProperty("content", "test");9artifact.setProperty("artifactType", "text/plain");10artifact.setProperty("artifactName", "test");11artifact.setProperty("artifactVersion", "1.0.0");12artifact.setProperty("artifactPath", "test");13artifact.setProperty("artifactDescription", "test");14artifact.setProperty("artifactMimeType", "text/plain");15artifact.setProperty("artifactContent", "test");16artifact.setProperty("artifactAttributes", "test");17artifact.setProperty("artifactProperties", "test");18artifact.setProperty("artifactDependencies", "test");
Using AI Code Generation
1function onCreateExternalArtifact() {2 var externalArtifact = root.createExternalArtifact('myExternalArtifact', 'myDescription');3}4function onCreateExternalArtifactFromTemplate() {5 var externalArtifact = root.createExternalArtifactFromTemplate('myExternalArtifact', 'myDescription', 'myTemplateExternalArtifact');6}7function onCreateExternalArtifactFromArtifact() {8 var externalArtifact = root.createExternalArtifactFromArtifact('myExternalArtifact', 'myDescription', 'myTemplateArtifact');9}10function onCreateExternalArtifactFromTemplate() {11 var externalArtifact = root.createExternalArtifactFromTemplate('myExternalArtifact', 'myDescription', 'myTemplateExternalArtifact', 'myNewName');12}13function onCreateExternalArtifactFromArtifact() {14 var externalArtifact = root.createExternalArtifactFromArtifact('myExternalArtifact', 'myDescription', 'myTemplateArtifact', 'myNewName');15}16function getExternalArtifact() {17 var externalArtifact = root.getExternalArtifact('myExternalArtifact');18}
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!