         iterator.start()
         // Manually run the run loop for a while to leave a chance to the completion handler to be called.
         // WARNING: We cannot use `self.waitForExpectations(timeout: )`, because a timeout always results in failure.
-        RunLoop.main.run(until: Date().addingTimeInterval(10))
+        RunLoop.main.run(until: Date().addingTimeInterval(cancelTimeout))
     }
 
 }

        index.addObjects(objects) { (content, error) -> Void in
            if error != nil {
                XCTFail("Error during addObjects: \(error!)")
                expectation2.fulfill()
            } else {
                self.index.waitTask(withID: content!["taskID"] as! Int) { (content, error) -> Void in
                    if error != nil {
                        XCTFail("Error during waitTask: \(error!)")
                    }
                    expectation2.fulfill()
                }
            }
        }
        self.waitForExpectations(timeout: expectationTimeout, handler: nil)
    }
    
    override func tearDown() {
        super.tearDown()
        
        let expectation = self.expectation(description: "Delete index")
        client.deleteIndex(withName: index.name, completionHandler: { (content, error) -> Void in
            XCTAssertNil(error, "Error during deleteIndex: \(error!)")
            expectation.fulfill()
        })
        
        self.waitForExpectations(timeout: expectationTimeout, handler: nil)
    }
    

import XCTest
import AlgoliaSearch

class BrowseIteratorTests: OnlineTestCase {
    let cancelTimeout: TimeInterval = 10
    
    override func setUp() {
        super.setUp()
        
        // Add a bunch of objects to the index.
        let expectation = self.expectation(description: "Add objects")
        var objects = [JSONObject]()
        for i in 0...1500 {
            objects.append(["i": i])
