SACRAMENTO — A pack of Teamsters fanned out through California’s Capitol building last week, marching into legislators’ offices and pressing them to pass a bill that would force Uber and Lyft to treat their drivers as employees. The measure, Assembly Bill 5, would entitle gig workers to protections like a minimum wage and unemployment benefits. “Yes on A.B. 5! Yes on A.B. 5!” they chorused.

The push was one of several door-knocking campaigns coordinated by labor groups that can now taste success after battling the ride-hailing companies for years.

The bill is intended to codify and extend a 2018 California Supreme Court ruling that put forth a new test for classifying workers. Under that test, workers are far more likely to be deemed employees if they perform a function central to a company’s business.

Legislators are expected to pass the bill before their session ends this week, presenting the strongest challenge yet to Uber and Lyft’s business model, which relies on a corps of drivers who can be enlisted and deployed essentially as freelancers.