The city government said on its official WeChat account that all residents in nine of the city's 16 districts would be tested twice from Tuesday to Thursday. People in parts of three other districts would also have to undergo tests.
The testing was needed because multiple COVID infections found this week were linked to a karaoke lounge, which had been visited by residents from several districts, it said.
"No household or person should be missed," the city government said of the testing.
During the testing, people living in the affected districts would be required to show a test taken within the last two days to leave their homes, it said.
City lockdowns and repeated mass testing in China, part of its zero-COVID policy that aims to eradicate all outbreaks, have brought case numbers down but many of the measures have fuelled anger and taken a toll on the economy.
Shanghai reported eight new local COVID cases on Monday, seven of which it said were found in quarantined areas.
The city already requires all of its districts to organise mass testing of residents every weekend until the end of July. Residents also need to test themselves every three days in order to enter public areas such as shopping malls or take public transport.
Although China's most populous city has lifted a two month-long lockdown of its 25 million residents, it still imposes targeted curbs on movements whenever a COVID case is found outside quarantined areas.
The northwestern city of Xian, which reported 18 local infections in a flare-up driven by the BA.5.2 sub-variant, will from Wednesday suspend operations at various entertainment venues, dining at restaurants and big events for seven days, a government official said.
(Reporting by the Shanghai Newsroom; Editing by Robert Birsel)